-
I would like to implement a View source link to view the source of the current page in site’s GitHub repo. I would to something like this: <a href="{{ site.repoUrl }}{{ SOMETHING_HERE }}">View source</a> which should produce something like: <a href="https://github.com/valtlai/valtlai.fi/blob/main/blog/hello.md">View source</a> Is there a good way? |
Beta Was this translation helpful? Give feedback.
Answered by
valtlai
May 20, 2021
Replies: 1 comment 1 reply
-
Found a solution. Is this the best approach? In repoUrl: https://github.com/valtlai/valtlai.fi/blob/main In site.preprocess([".html"], (page) => {
page.data.srcUrl = page.src.path + page.src.ext;
}); In a layout file: <a href="{{ site.repoUrl }}{{ srcUrl }}">View source</a> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
valtlai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found a solution. Is this the best approach?
In
_data/site.yml
, I have:In
_config.js
:In a layout file: