From 825893d52cc2ba54bc1665550afab438164b5c36 Mon Sep 17 00:00:00 2001 From: Ole Eskild Steensen Date: Fri, 5 Aug 2022 14:38:41 +0200 Subject: [PATCH] Fix #64: Support links ending in .md 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. --- .eleventy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.eleventy.js b/.eleventy.js index 0d9811fbc..3ee118bc1 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -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;