Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Declarative Section Type Matching with helix-markup.yaml #606

Description

@trieloff

This is an extension of #516 and depends on #533

So far, helix-markup.yaml is capable of matching DOM elements and lower-level MDAST structures, but when it comes to sections, the features provided by #533 include only the ability to:

  • control which of the inferred types from content.section[].types should show up in the section tag's class attribute
  • control if a section should be rendered as a div (default), section, nav, main, header, footer, or any other HTML element

With this extension, developers will furthermore be able to:

  • control which types are inferred without using utils.types imperatively
  • infer section types based on URL patterns

For this, helix-markup.yaml will get a new optional key, sections:

sections:
  navigation:
    content: ^heading? list+$
    uri: /nav.html

markup:
  navigation:
    match: section[@type=navigation]
    type: markdown
    wrap: nav

In the example above, if a URL matching /nav.html (we support URI Template expressions) is requested, and there is a section containing one optional heading at the beginning and a series of lists, then that section should get a type with the value navigation (in addition to the automatically inferred types).

In the second part of the example, sections in MDAST with a type that contains navigation are getting wrapped in nav elements.

/cc @davidnuescheler

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions