2022-06-01 10:26:43 +02:00
|
|
|
const pluginRss = require('@11ty/eleventy-plugin-rss');
|
2023-04-12 21:58:52 +02:00
|
|
|
const { EleventyRenderPlugin } = require('@11ty/eleventy');
|
2022-06-01 10:26:43 +02:00
|
|
|
|
|
|
|
// Markdown //
|
2023-04-12 21:58:52 +02:00
|
|
|
function wikilinkSlugifier(pageName) {
|
|
|
|
pageName = pageName.replace(/\s+/, '-');
|
|
|
|
pageName = slugify(pageName, {
|
|
|
|
remove: /'/g,
|
|
|
|
lower: true
|
|
|
|
});
|
|
|
|
return pageName
|
|
|
|
}
|
2022-06-01 10:26:43 +02:00
|
|
|
const markdownIt = require('markdown-it');
|
|
|
|
const md = markdownIt({
|
2023-04-12 21:58:52 +02:00
|
|
|
html: true,
|
|
|
|
typographer: true
|
|
|
|
})
|
|
|
|
.use(require('markdown-it-wikilinks')({
|
|
|
|
uriSuffix: '',
|
|
|
|
makeAllLinksAbsolute: true,
|
|
|
|
class: 'wikilink',
|
|
|
|
postProcessPageName: wikilinkSlugifier
|
|
|
|
}))
|
|
|
|
.use(require('markdown-it-anchor'), {
|
|
|
|
permalink: require('markdown-it-anchor').permalink.headerLink(),
|
|
|
|
})
|
|
|
|
.use(require('markdown-it-footnote'))
|
|
|
|
.use(require('markdown-it-mark'))
|
|
|
|
.use(require('markdown-it-task-lists'))
|
|
|
|
.use(require('markdown-it-mathjax3'));
|
|
|
|
|
|
|
|
const { default: slugify } = require('slugify');
|
2022-06-01 10:26:43 +02:00
|
|
|
|
|
|
|
module.exports = function(eleventyConfig) {
|
|
|
|
// General //
|
|
|
|
eleventyConfig.setLibrary('md', md);
|
|
|
|
eleventyConfig.addDataExtension('csv', contents => require('csv-parse/sync').parse(contents, {columns: true, skip_empty_lines: true}));
|
2023-04-12 21:58:52 +02:00
|
|
|
|
|
|
|
eleventyConfig.addGlobalData('permalink', () => {
|
|
|
|
return (data) => slugify(`${data.page.fileSlug}`, {
|
|
|
|
remove: /'/g,
|
|
|
|
lower: true
|
|
|
|
}).concat('/');
|
|
|
|
});
|
2022-06-01 10:26:43 +02:00
|
|
|
|
|
|
|
// Multilingual sitemap collection. See https://github.com/quasibit/eleventy-plugin-sitemap#create-a-multilingual-sitemap
|
|
|
|
eleventyConfig.addCollection('sitemap', function(collectionApi) {
|
|
|
|
return collectionApi
|
|
|
|
.getAll()
|
|
|
|
.map((item, index, all) => {
|
|
|
|
return {
|
|
|
|
url: item.url,
|
|
|
|
date: item.date,
|
|
|
|
data: {
|
|
|
|
...item.data,
|
|
|
|
sitemap: {
|
|
|
|
...item.data.sitemap,
|
|
|
|
links:
|
|
|
|
all
|
|
|
|
.filter(other => other.data.ref === item.data.ref)
|
|
|
|
.map(translation => {
|
|
|
|
return {
|
|
|
|
url: translation.url,
|
|
|
|
lang: translation.data.lang,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
eleventyConfig.addPassthroughCopy({'svg': '/'});
|
2023-04-12 21:58:52 +02:00
|
|
|
eleventyConfig.addPassthroughCopy('index.js');
|
2022-06-01 10:26:43 +02:00
|
|
|
|
|
|
|
// Plugins //
|
|
|
|
eleventyConfig.addPlugin(require('@11ty/eleventy-plugin-syntaxhighlight'));
|
|
|
|
eleventyConfig.addPlugin(require('@aloskutov/eleventy-plugin-external-links'), {
|
|
|
|
url: 'https://quitsocialmedia.club',
|
|
|
|
rel: ['noreferrer', 'noopener', 'external'],
|
|
|
|
overwrite: false,
|
|
|
|
});
|
|
|
|
eleventyConfig.addPlugin(require('eleventy-plugin-embed-everything'), {
|
|
|
|
youtube: {
|
|
|
|
options: {
|
|
|
|
embedClass: 'embed',
|
|
|
|
lite: {
|
|
|
|
css: {
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
spotify: {
|
|
|
|
options: {
|
|
|
|
embedClass: 'embed',
|
|
|
|
width: '100%'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
instagram: {
|
|
|
|
options: {
|
|
|
|
embedClass: 'embed'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2023-04-12 21:58:52 +02:00
|
|
|
eleventyConfig.addPlugin(EleventyRenderPlugin);
|
|
|
|
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
|
|
|
compileOptions: {
|
|
|
|
permalink: function(contents, inputPath) {
|
|
|
|
return (data) => data.page.filePathStem.replace(/^\/styles\//, '/') + '.css';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
style: 'compressed'
|
|
|
|
}
|
|
|
|
});
|
2022-06-01 10:26:43 +02:00
|
|
|
eleventyConfig.addPlugin(require('eleventy-plugin-svg-contents'));
|
|
|
|
eleventyConfig.addPlugin(require('@sardine/eleventy-plugin-tinysvg'), {
|
2022-09-18 09:30:04 +02:00
|
|
|
baseUrl: 'svg/'
|
2022-06-01 10:26:43 +02:00
|
|
|
});
|
|
|
|
eleventyConfig.addPlugin(require('eleventy-plugin-toc'), {
|
|
|
|
ul: true,
|
|
|
|
});
|
|
|
|
eleventyConfig.addPlugin(pluginRss);
|
|
|
|
eleventyConfig.addPlugin(require('@quasibit/eleventy-plugin-sitemap'), {
|
|
|
|
sitemap: {
|
|
|
|
hostname: 'https://quitsocialmedia.club'
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Filters //
|
|
|
|
eleventyConfig.addFilter('reverse', (collection) => {
|
|
|
|
const arr = [...collection];
|
|
|
|
return arr.reverse();
|
|
|
|
});
|
|
|
|
eleventyConfig.addFilter('markdownify', (str) => {
|
|
|
|
return md.renderInline(str);
|
|
|
|
});
|
|
|
|
// RSS Filters //
|
|
|
|
eleventyConfig.addFilter('dateToRfc3339', pluginRss.dateToRfc3339);
|
|
|
|
eleventyConfig.addFilter('getNewestCollectionItemDate', pluginRss.getNewestCollectionItemDate);
|
|
|
|
eleventyConfig.addFilter('absoluteUrl', pluginRss.absoluteUrl);
|
|
|
|
eleventyConfig.addFilter('convertHtmlToAbsoluteUrls', pluginRss.convertHtmlToAbsoluteUrls);
|
|
|
|
|
2023-04-12 21:58:52 +02:00
|
|
|
// Production-only //
|
|
|
|
if (process.env.ELEVENTY_ENV == 'production') {
|
|
|
|
// Minify output //
|
|
|
|
eleventyConfig.addTransform(require('html-minifier'), function(content, outputPath) {
|
|
|
|
if( this.outputPath && this.outputPath.endsWith('.html') ) {
|
|
|
|
let minified = require('html-minifier').minify(content, {
|
|
|
|
useShortDoctype: true,
|
|
|
|
removeComments: true,
|
|
|
|
collapseWhitespace: true,
|
|
|
|
minifyCSS: true,
|
|
|
|
minifyJS: true,
|
|
|
|
minifyURLs: true
|
2022-06-01 10:26:43 +02:00
|
|
|
});
|
2023-04-12 21:58:52 +02:00
|
|
|
return minified;
|
2022-06-01 10:26:43 +02:00
|
|
|
}
|
2023-04-12 21:58:52 +02:00
|
|
|
return content;
|
|
|
|
});
|
|
|
|
eleventyConfig.addPlugin(require('eleventy-plugin-purgecss'));
|
|
|
|
}
|
|
|
|
|
|
|
|
eleventyConfig.on('eleventy.after', () => {
|
|
|
|
const execSync = require('child_process').execSync;
|
|
|
|
execSync(`npx pagefind`, { encoding: 'utf-8' });
|
|
|
|
})
|
2022-06-01 10:26:43 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
dir: {
|
|
|
|
includes: 'includes',
|
|
|
|
layouts: 'layouts',
|
|
|
|
data: 'data',
|
|
|
|
output: 'www'
|
|
|
|
}
|
|
|
|
}; // there should never be anything after the “return” function
|
|
|
|
};
|