meta updates

This commit is contained in:
Cory Dransfeldt 2023-03-11 18:03:54 -08:00
parent 70c52e6a37
commit 2809018dc1
No known key found for this signature in database
6 changed files with 154 additions and 55 deletions

View file

@ -1,63 +1,69 @@
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const filters = require('./config/filters.js')
module.exports = function(eleventyConfig) {
// Plugins
eleventyConfig.addPlugin(syntaxHighlight)
// To enable merging of tags
eleventyConfig.setDataDeepMerge(true)
module.exports = function (eleventyConfig) {
// Plugins
eleventyConfig.addPlugin(syntaxHighlight)
// Copy these static files to _site folder
eleventyConfig.addPassthroughCopy('src/assets')
eleventyConfig.addPassthroughCopy('src/manifest.json')
// To create excerpts
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_alias: 'post_excerpt',
excerpt_separator: '<!-- excerpt -->'
})
// To create a filter to determine duration of post
eleventyConfig.addFilter('readTime', (value) => {
const content = value
const textOnly = content.replace(/(<([^>]+)>)/gi, '')
const readingSpeedPerMin = 450
return Math.max(1, Math.floor(textOnly.length / readingSpeedPerMin))
})
// Enable us to iterate over all the tags, excluding posts and all
eleventyConfig.addCollection('tagList', collection => {
const tagsSet = new Set()
collection.getAll().forEach(item => {
if (!item.data.tags) return
item.data.tags
.filter(tag => !['posts', 'all'].includes(tag))
.forEach(tag => tagsSet.add(tag))
// filters
Object.keys(filters).forEach((filterName) => {
eleventyConfig.addFilter(filterName, filters[filterName])
})
return Array.from(tagsSet).sort()
})
const md = markdownIt({ html: true, linkify: true })
md.use(markdownItAnchor, {
level: [1, 2],
permalink: markdownItAnchor.permalink.headerLink({
safariReaderFix: true,
class: 'header-anchor',
// To enable merging of tags
eleventyConfig.setDataDeepMerge(true)
// Copy these static files to _site folder
eleventyConfig.addPassthroughCopy('src/assets')
eleventyConfig.addPassthroughCopy('src/manifest.json')
// To create excerpts
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_alias: 'post_excerpt',
excerpt_separator: '<!-- excerpt -->',
})
})
eleventyConfig.setLibrary('md', md)
// asset_img shortcode
eleventyConfig.addLiquidShortcode('asset_img', (filename, alt) => {
return `<img class="my-4" src="/assets/img/posts/${filename}" alt="${alt}" />`
})
// To create a filter to determine duration of post
eleventyConfig.addFilter('readTime', (value) => {
const content = value
const textOnly = content.replace(/(<([^>]+)>)/gi, '')
const readingSpeedPerMin = 450
return Math.max(1, Math.floor(textOnly.length / readingSpeedPerMin))
})
return {
dir: {
input: 'src'
// Enable us to iterate over all the tags, excluding posts and all
eleventyConfig.addCollection('tagList', (collection) => {
const tagsSet = new Set()
collection.getAll().forEach((item) => {
if (!item.data.tags) return
item.data.tags
.filter((tag) => !['posts', 'all'].includes(tag))
.forEach((tag) => tagsSet.add(tag))
})
return Array.from(tagsSet).sort()
})
const md = markdownIt({ html: true, linkify: true })
md.use(markdownItAnchor, {
level: [1, 2],
permalink: markdownItAnchor.permalink.headerLink({
safariReaderFix: true,
class: 'header-anchor',
}),
})
eleventyConfig.setLibrary('md', md)
// asset_img shortcode
eleventyConfig.addLiquidShortcode('asset_img', (filename, alt) => {
return `<img class="my-4" src="/assets/img/posts/${filename}" alt="${alt}" />`
})
return {
dir: {
input: 'src',
},
}
}
}