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.
This commit is contained in:
Ole Eskild Steensen 2022-08-05 14:38:41 +02:00
parent 3836163a2c
commit 825893d52c

View File

@ -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;