middleman / middleman-asciidoc

:beginner: AsciiDoc support for Middleman 4. (In Middleman 3, AsciiDoc support is provided by a core extension).
https://middlemanapp.com
Other
27 stars 12 forks source link

Extend xref macro to support referencing a page by page ID #69

Open mojavelinux opened 6 years ago

mojavelinux commented 6 years ago

Each resource in the sitemap of a Middleman site has a page ID, whether implicit or explicit. The page ID can be used to create a reference to a resource. In a template context, the url_for helper is used for this purpose. Extend the AsciiDoc xref macro to support create page references by page ID in an AsciiDoc document, effectively emulating the behavior of the url_for helper.

This extended behavior needs to be distinguished from a normal inter-document xref. This can either by done by:

a) requiring the page ID to be prefixed with /, or b) requiring a normal inter-document xref to be prefixed with ./.

Here's an example of a page reference under proposal a).

xref:/about#[]

Here's an example of a page reference under proposal b)

xref:about#[]

Another idea is to require the extension, .adoc, to make a normal inter-document xref. This works since the page ID does not include the extension.