Skip to content

Commit

Permalink
format with semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
ooloth committed Jun 6, 2023
1 parent 87530eb commit 4eb5f1b
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ printWidth: 100
proseWrap: preserve
quoteProps: as-needed
requirePragma: false
semi: false
semi: true
singleQuote: true
tabWidth: 2
trailingComma: all
Expand Down
36 changes: 18 additions & 18 deletions eleventy.config.drafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
});
};
24 changes: 12 additions & 12 deletions eleventy.config.images.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
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
// https://www.11ty.dev/docs/plugins/image/
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 = {
alt,
sizes,
loading: 'lazy',
decoding: 'async',
}
return eleventyImage.generateHTML(metadata, imageAttributes)
})
}
};
return eleventyImage.generateHTML(metadata, imageAttributes);
});
};
90 changes: 45 additions & 45 deletions eleventy.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
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
// For example, `./public/css/` ends up in `_site/css/`
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',
Expand All @@ -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 => {
Expand All @@ -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)

Expand Down Expand Up @@ -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: '/',
}
}
};
};
2 changes: 1 addition & 1 deletion src/_data/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module.exports = {
email: 'michaeluloth@gmail.com',
url: 'https://michaeluloth.com/about/',
},
}
};
4 changes: 2 additions & 2 deletions src/_includes/components/copyright.webc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script webc:type="js">
const now = new Date()
const now = new Date();

;`&copy; ${now.getFullYear()} Michael Uloth.`
`&copy; ${now.getFullYear()} Michael Uloth.`;
</script>
4 changes: 2 additions & 2 deletions src/_includes/components/meta-title.webc
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

;`<title>${metaTitle}</title>`
`<title>${metaTitle}</title>`;
</script>
2 changes: 1 addition & 1 deletion src/feed/feed.11tydata.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
eleventyExcludeFromCollections: true,
}
};

0 comments on commit 4eb5f1b

Please sign in to comment.