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

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

Open
trieloff opened this issue Mar 2, 2020 · 0 comments
Open

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

trieloff opened this issue Mar 2, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@trieloff
Copy link
Contributor

trieloff commented Mar 2, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant