Skip to content

Commit

Permalink
Fix #64: Support links ending in .md
Browse files Browse the repository at this point in the history
Some dataview queries adds a .md file extension on links to other
pages. This caused the digital garden to search for filename.md.md,
which it didn't find. Thus dataview queries could result in dead links
that weren't really dead. This commit should fix that.
  • Loading branch information
oleeskild committed Aug 5, 2022
1 parent 3836163 commit 825893d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ module.exports = function(eleventyConfig) {


try {
const file = fs.readFileSync(`./src/site/notes/${fileName}.md`, 'utf8');
const startPath = './src/site/notes/';
const fullPath = fileName.endsWith('.md') ?
`${startPath}${fileName}`
:`${startPath}${fileName}.md`;
const file = fs.readFileSync(fullPath, 'utf8');
const frontMatter = matter(file);
if (frontMatter.data.permalink) {
permalink = frontMatter.data.permalink;
Expand Down

0 comments on commit 825893d

Please sign in to comment.