Skip to content

Commit

Permalink
markdown working
Browse files Browse the repository at this point in the history
  • Loading branch information
MoNouri97 committed Mar 21, 2021
1 parent 49a63f9 commit ea7a170
Show file tree
Hide file tree
Showing 23 changed files with 940 additions and 185 deletions.
59 changes: 50 additions & 9 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation')
const eleventyNavigationPlugin = require('@11ty/eleventy-navigation');
const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
// const pluginRss = require('@11ty/eleventy-plugin-rss')
const markdownItAnchor = require('markdown-it-anchor');

const formatYear = new Intl.DateTimeFormat('en', { year: 'numeric' });
const formatMonth = new Intl.DateTimeFormat('en', { month: 'short' });
const formatDay = new Intl.DateTimeFormat('en', { day: '2-digit' });
const md = require('markdown-it');
const mdContainer = require('markdown-it-container');

const markdown = md({ html: true, breaks: true, linkify: true }).use(
mdContainer,
'codeblock',
{
render: function (tokens, idx) {
if (tokens[idx].type === 'container_codeblock_open') {
return `
<div class="rounded-lg shadow-lg">
`;
}
return `</div>`;
},
}
);
module.exports = (config) => {
config.addPassthroughCopy({ public: './' })
config.addPlugin(eleventyNavigationPlugin)
config.addPassthroughCopy({ public: './' });
// plugins
config.addPlugin(eleventyNavigationPlugin);
config.addPlugin(pluginSyntaxHighlight);
// config
config.setLibrary('md', markdown);

config.setBrowserSyncConfig({
files: ['dist/**/*'],
Expand All @@ -12,18 +39,32 @@ module.exports = (config) => {
rule: {
match: /<\/head>/i,
fn: function (snippet, match) {
return snippet + match
return snippet + match;
},
},
},
})
config.setDataDeepMerge(true)
});
config.setDataDeepMerge(true);
// Nunjucks Filter
config.addNunjucksFilter('displayDate', function (d) {
const ye = formatYear.format(d);
const mo = formatMonth.format(d);
const da = formatDay.format(d);
return `${da} ${mo} ${ye}`;
});
config.addNunjucksFilter('displayTags', function (tags) {
// should match the list in tags.njk
return (tags || []).filter(
(tag) => ['all', 'nav', 'note', 'article'].indexOf(tag) === -1
);
});

return {
templateFormats: ['md', 'njk', 'html', 'liquid'],
templateFormats: ['md', 'njk', 'html'],
markdownTemplateEngine: false,
dir: {
input: 'src',
output: 'dist',
},
}
}
};
};
Loading

0 comments on commit ea7a170

Please sign in to comment.