Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the canonical path to the current document when rendering. #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Include the canonical path to the current document when rendering. #25

wants to merge 1 commit into from

Conversation

ojacobson
Copy link

Given a document in WIKI_ROOT/foo/bar.md, it's tricky to reconsruct "foo/bar" or "foo/bar.html" or "foo/bar.md" from the breadcrumbs. A similar bit of context (named "directory") is already passed to directory templates; now markdoc passes the document path to the document template too.

I'm using this in my own markdoc instance to generate "page history" links (to github) for each page.

I'm not sure my implementation is entirely correct; while my experiments only show that path is a wiki-root-relative path (given ~/bliki/wiki/git/survival.md, path was always git/survival.md) other code makes me suspect that it's possible for path to be absolute. Needs the opinion of someone with more experience with this code than I have.

…ocument.

Given a document in WIKI_ROOT/foo/bar.md, it's tricky to reconsruct "foo/bar"
or "foo/bar.html" or "foo/bar.md" from the breadcrumbs. A similar bit of
context (named "directory") is already passed to directory templates; now
markdoc passes the document path to the document template too.

I'm using this in my own markdoc instance to generate "page history" links (to
github) for each page.
@ojacobson
Copy link
Author

I'm using this to generate the Github links in the footer of, for example, http://grimoire.ca/dev/builds. The relevant template bit looks like

<a href="https://raw.github.com/ojacobson/grimoiredotca/master/wiki/{{ path }}.md">See this page on GitHub</a> (<a href="https://github.com/ojacobson/grimoiredotca/commits/master/wiki/{{ path }}.md">history</a>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant