diff --git a/.prettierrc.yaml b/.prettierrc.yaml index dc14f51..8bc2302 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -16,7 +16,7 @@ printWidth: 100 proseWrap: preserve quoteProps: as-needed requirePragma: false -semi: false +semi: true singleQuote: true tabWidth: 2 trailingComma: all diff --git a/eleventy.config.drafts.js b/eleventy.config.drafts.js index c75bbae..ce20882 100644 --- a/eleventy.config.drafts.js +++ b/eleventy.config.drafts.js @@ -4,11 +4,11 @@ function eleventyComputedPermalink() { return data => { // Always skip during non-watch/serve builds if (data.draft && !process.env.BUILD_DRAFTS) { - return false + return false; } - return data.permalink - } + return data.permalink; + }; } function eleventyComputedExcludeFromCollections() { @@ -17,37 +17,37 @@ function eleventyComputedExcludeFromCollections() { return data => { // Always exclude from non-watch/serve builds if (data.draft && !process.env.BUILD_DRAFTS) { - return true + return true; } - return data.eleventyExcludeFromCollections - } + return data.eleventyExcludeFromCollections; + }; } -module.exports.eleventyComputedPermalink = eleventyComputedPermalink -module.exports.eleventyComputedExcludeFromCollections = eleventyComputedExcludeFromCollections +module.exports.eleventyComputedPermalink = eleventyComputedPermalink; +module.exports.eleventyComputedExcludeFromCollections = eleventyComputedExcludeFromCollections; module.exports = eleventyConfig => { - eleventyConfig.addGlobalData('eleventyComputed.permalink', eleventyComputedPermalink) + eleventyConfig.addGlobalData('eleventyComputed.permalink', eleventyComputedPermalink); eleventyConfig.addGlobalData( 'eleventyComputed.eleventyExcludeFromCollections', eleventyComputedExcludeFromCollections, - ) + ); - let logged = false + let logged = false; eleventyConfig.on('eleventy.before', ({ runMode }) => { - let text = 'Excluding' + let text = 'Excluding'; // Only show drafts in serve/watch modes if (runMode === 'serve' || runMode === 'watch') { - process.env.BUILD_DRAFTS = true - text = 'Including' + process.env.BUILD_DRAFTS = true; + text = 'Including'; } // Only log once. if (!logged) { - console.log(`[11ty/eleventy-base-blog] ${text} drafts.`) + console.log(`[11ty/eleventy-base-blog] ${text} drafts.`); } - logged = true - }) -} + logged = true; + }); +}; diff --git a/eleventy.config.images.js b/eleventy.config.images.js index 13b2555..0a38e49 100644 --- a/eleventy.config.images.js +++ b/eleventy.config.images.js @@ -1,12 +1,12 @@ -const path = require('path') -const eleventyImage = require('@11ty/eleventy-img') +const path = require('path'); +const eleventyImage = require('@11ty/eleventy-img'); module.exports = eleventyConfig => { function relativeToInputPath(inputPath, relativeFilePath) { - let split = inputPath.split('/') - split.pop() + let split = inputPath.split('/'); + split.pop(); - return path.resolve(split.join(path.sep), relativeFilePath) + return path.resolve(split.join(path.sep), relativeFilePath); } // Eleventy Image shortcode @@ -14,13 +14,13 @@ module.exports = eleventyConfig => { eleventyConfig.addAsyncShortcode('image', async function imageShortcode(src, alt, widths, sizes) { // Full list of formats here: https://www.11ty.dev/docs/plugins/image/#output-formats // Warning: Avif can be resource-intensive so take care! - let formats = ['avif', 'webp', 'auto'] - let file = relativeToInputPath(this.page.inputPath, src) + let formats = ['avif', 'webp', 'auto']; + let file = relativeToInputPath(this.page.inputPath, src); let metadata = await eleventyImage(file, { widths: widths || ['auto'], formats, outputDir: path.join(eleventyConfig.dir.output, 'img'), // Advanced usage note: `eleventyConfig.dir` works here because we’re using addPlugin. - }) + }); // TODO loading=eager and fetchpriority=high let imageAttributes = { @@ -28,7 +28,7 @@ module.exports = eleventyConfig => { sizes, loading: 'lazy', decoding: 'async', - } - return eleventyImage.generateHTML(metadata, imageAttributes) - }) -} + }; + return eleventyImage.generateHTML(metadata, imageAttributes); + }); +}; diff --git a/eleventy.config.js b/eleventy.config.js index d2d39b7..3d39130 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,15 +1,15 @@ -const { DateTime } = require('luxon') -const markdownItAnchor = require('markdown-it-anchor') +const { DateTime } = require('luxon'); +const markdownItAnchor = require('markdown-it-anchor'); -const { EleventyHtmlBasePlugin } = require('@11ty/eleventy') -const pluginBundle = require('@11ty/eleventy-plugin-bundle') -const pluginNavigation = require('@11ty/eleventy-navigation') -const pluginRss = require('@11ty/eleventy-plugin-rss') -const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight') -const pluginWebC = require('@11ty/eleventy-plugin-webc') +const { EleventyHtmlBasePlugin } = require('@11ty/eleventy'); +const pluginBundle = require('@11ty/eleventy-plugin-bundle'); +const pluginNavigation = require('@11ty/eleventy-navigation'); +const pluginRss = require('@11ty/eleventy-plugin-rss'); +const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); +const pluginWebC = require('@11ty/eleventy-plugin-webc'); -const pluginDrafts = require('./eleventy.config.drafts.js') -const pluginImages = require('./eleventy.config.images.js') +const pluginDrafts = require('./eleventy.config.drafts.js'); +const pluginImages = require('./eleventy.config.images.js'); module.exports = function (eleventyConfig) { // Copy the contents of the `public` folder to the output folder @@ -17,22 +17,22 @@ module.exports = function (eleventyConfig) { eleventyConfig.addPassthroughCopy({ './public/': '/', './node_modules/prismjs/themes/prism-okaidia.css': '/css/prism-okaidia.css', - }) + }); // Run Eleventy when these files change: // https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets // Watch content images for the image pipeline. - eleventyConfig.addWatchTarget('content/**/*.{svg,webp,png,jpeg}') + eleventyConfig.addWatchTarget('content/**/*.{svg,webp,png,jpeg}'); // Official plugins - eleventyConfig.addPlugin(EleventyHtmlBasePlugin) - eleventyConfig.addPlugin(pluginBundle) - eleventyConfig.addPlugin(pluginNavigation) - eleventyConfig.addPlugin(pluginRss) + eleventyConfig.addPlugin(EleventyHtmlBasePlugin); + eleventyConfig.addPlugin(pluginBundle); + eleventyConfig.addPlugin(pluginNavigation); + eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(pluginSyntaxHighlight, { preAttributes: { tabindex: 0 }, - }) + }); eleventyConfig.addPlugin(pluginWebC, { // Glob to find no-import global components components: 'src/_includes/components/**/*.webc', @@ -45,70 +45,70 @@ module.exports = function (eleventyConfig) { // Options passed to @11ty/eleventy-plugin-bundle bundlePluginOptions: {}, - }) + }); // Local plugins - eleventyConfig.addPlugin(pluginDrafts) - eleventyConfig.addPlugin(pluginImages) + eleventyConfig.addPlugin(pluginDrafts); + eleventyConfig.addPlugin(pluginImages); // Collections eleventyConfig.addCollection('posts', function (collectionApi) { // See: https://www.11ty.dev/docs/collections/#getfilteredbyglob(-glob-) - return collectionApi.getFilteredByGlob('src/content/posts/**/*.md') - }) + return collectionApi.getFilteredByGlob('src/content/posts/**/*.md'); + }); eleventyConfig.addCollection('notes', function (collectionApi) { // See: https://www.11ty.dev/docs/collections/#getfilteredbyglob(-glob-) - return collectionApi.getFilteredByGlob('src/content/topics/*.md') - }) + return collectionApi.getFilteredByGlob('src/content/topics/*.md'); + }); // Extensions // See: https://www.11ty.dev/docs/languages/custom/#aliasing-an-existing-template-language // See: https://gist.github.com/zachleat/b274ee939759b032bc320be1a03704a2 eleventyConfig.addExtension(['11ty.ts', '11ty.tsx'], { key: '11ty.js', - }) + }); // Filters eleventyConfig.addFilter('readableDate', (dateObj, format, zone) => { // Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens - return DateTime.fromJSDate(dateObj, { zone: zone || 'utc' }).toFormat(format || 'dd LLLL yyyy') - }) + return DateTime.fromJSDate(dateObj, { zone: zone || 'utc' }).toFormat(format || 'dd LLLL yyyy'); + }); eleventyConfig.addFilter('htmlDateString', dateObj => { // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string - return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd') - }) + return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd'); + }); // Get the first `n` elements of a collection. eleventyConfig.addFilter('head', (array, n) => { if (!Array.isArray(array) || array.length === 0) { - return [] + return []; } if (n < 0) { - return array.slice(n) + return array.slice(n); } - return array.slice(0, n) - }) + return array.slice(0, n); + }); // Return the smallest number argument eleventyConfig.addFilter('min', (...numbers) => { - return Math.min.apply(null, numbers) - }) + return Math.min.apply(null, numbers); + }); // Return all the tags used in a collection eleventyConfig.addFilter('getAllTags', collection => { - let tagSet = new Set() + let tagSet = new Set(); for (let item of collection) { - ;(item.data.tags || []).forEach(tag => tagSet.add(tag)) + (item.data.tags || []).forEach(tag => tagSet.add(tag)); } - return Array.from(tagSet) - }) + return Array.from(tagSet); + }); eleventyConfig.addFilter('filterTagList', function filterTagList(tags) { - return (tags || []).filter(tag => ['all', 'nav', 'post', 'posts'].indexOf(tag) === -1) - }) + return (tags || []).filter(tag => ['all', 'nav', 'post', 'posts'].indexOf(tag) === -1); + }); // Customize Markdown library settings: eleventyConfig.amendLibrary('md', mdLib => { @@ -121,8 +121,8 @@ module.exports = function (eleventyConfig) { }), level: [1, 2, 3, 4], slugify: eleventyConfig.getFilter('slugify'), - }) - }) + }); + }); // Features to make your build faster (when you need them) @@ -162,5 +162,5 @@ module.exports = function (eleventyConfig) { // it will transform any absolute URLs in your HTML to include this // folder name and does **not** affect where things go in the output folder. pathPrefix: '/', - } -} + }; +}; diff --git a/src/_data/site.js b/src/_data/site.js index 9d18891..a394f12 100644 --- a/src/_data/site.js +++ b/src/_data/site.js @@ -8,4 +8,4 @@ module.exports = { email: 'michaeluloth@gmail.com', url: 'https://michaeluloth.com/about/', }, -} +}; diff --git a/src/_includes/components/copyright.webc b/src/_includes/components/copyright.webc index 89b83c6..4dce33d 100644 --- a/src/_includes/components/copyright.webc +++ b/src/_includes/components/copyright.webc @@ -1,5 +1,5 @@ diff --git a/src/_includes/components/meta-title.webc b/src/_includes/components/meta-title.webc index 0e6fbd0..d6e0e64 100644 --- a/src/_includes/components/meta-title.webc +++ b/src/_includes/components/meta-title.webc @@ -4,7 +4,7 @@ // If the current page's frontmatter includes a "title", put it before the site title // Must access data via $data in components (but not in layouts or top-level pages) // See: https://github.com/11ty/webc/issues/152 - const metaTitle = title ? `${title} | ${$data.site.title}` : `${$data.site.title}` + const metaTitle = title ? `${title} | ${$data.site.title}` : `${$data.site.title}`; - ;`${metaTitle}` + `${metaTitle}`; diff --git a/src/feed/feed.11tydata.js b/src/feed/feed.11tydata.js index f5e3910..1cfb0fe 100644 --- a/src/feed/feed.11tydata.js +++ b/src/feed/feed.11tydata.js @@ -1,3 +1,3 @@ module.exports = { eleventyExcludeFromCollections: true, -} +};