implemented eleventy filter for links
This commit is contained in:
parent
fb24c6a302
commit
c8223447a0
41 changed files with 230 additions and 205 deletions
|
|
@ -3,35 +3,30 @@ import markdownItAnchor from "markdown-it-anchor";
|
|||
import { format } from "date-fns";
|
||||
|
||||
export default async function (eleventyConfig) {
|
||||
|
||||
const markdownItOptions = {
|
||||
html: true
|
||||
};
|
||||
|
||||
const markdownItAnchorOptions = {
|
||||
permalink: true, permalinkBefore: true, permalinkSymbol: '#'
|
||||
};
|
||||
|
||||
const markdownLib = markdownIt(markdownItOptions).use(
|
||||
markdownItAnchor,
|
||||
markdownItAnchorOptions
|
||||
);
|
||||
|
||||
eleventyConfig.setLibrary("md", markdownLib);
|
||||
|
||||
const assets = "./_src/assets/";
|
||||
eleventyConfig.addPassthroughCopy(assets);
|
||||
eleventyConfig.addWatchTarget(assets);
|
||||
|
||||
eleventyConfig.addFilter("sortByFirstDate", items => items.sort((a, b) => new Date(b.data.images[0].date) - new Date(a.data.images[0].date)));
|
||||
|
||||
eleventyConfig.addFilter("link", function(text, url) {
|
||||
return `<span class="link"><a href="${url}"><img src="https://www.google.com/s2/favicons?domain=${url}" alt=""/>${text}</a></span>`;
|
||||
});
|
||||
eleventyConfig.addFilter("ISO", (dateObj) => {
|
||||
return format(dateObj, ("yyyy-LL-dd"));
|
||||
});
|
||||
eleventyConfig.addFilter("readable", (dateObj) => {
|
||||
return format(dateObj, ("LLLL do, yyyy"));
|
||||
});
|
||||
|
||||
eleventyConfig.setBrowserSyncConfig({
|
||||
open: true,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue