Skip to content

Commit ed3b906

Browse files
committed
fix: format edit-icon-path in collection config
1 parent 5204a34 commit ed3b906

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/_includes/edit_button.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
{% assign pagePath = page.inputPath | replace: "./", "" | replace: "_guides", "guides" %}
21
<a
32
data-toggle="tooltip"
43
data-placement="top"
54
title="Edit this on Github"
65
class="icon-edit"
7-
href="{{ site.github.repository_url }}/edit/master/docs/{{ pagePath }}"
6+
href="{{ site.github.repository_url }}/edit/master/docs/{{ page.inputPath | formatInputPath }}"
87
target="_blank"
98
></a>

docs/eleventy.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ module.exports = eleventyConfig => {
1818
eleventyConfig.addGlobalData('permalink', '/{{ page.filePathStem }}.html');
1919

2020
eleventyConfig.addCollection('guides', collectionApi => {
21-
return collectionApi.getFilteredByTag('guides').sort((a, b) => a.data.index - b.data.index);
21+
return collectionApi
22+
.getFilteredByTag('guides')
23+
.sort((a, b) => a.data.index - b.data.index);
2224
});
2325

2426
eleventyConfig.addCollection('pages', collectionApi => {
@@ -43,6 +45,10 @@ module.exports = eleventyConfig => {
4345
.sort((a, b) => b.date - a.date || b.inputPath.localeCompare(a.inputPath));
4446
});
4547

48+
eleventyConfig.addFilter("formatInputPath", function(value) {
49+
return value.replace("./", "").replace("_guides", "guides").replace("_posts", "post");
50+
});
51+
4652
eleventyConfig.addFilter('first_paragraph', function(content) {
4753
const marker = '</p>';
4854
const idx = content.indexOf(marker);

0 commit comments

Comments
 (0)