formate eleventy.js properly

This commit is contained in:
2023-03-28 15:20:36 +10:30
parent 155e51f4e2
commit 2e23103e63

View File

@ -17,7 +17,7 @@ module.exports = function (eleventyConfig) {
collectionApi.getAll().map(item => { collectionApi.getAll().map(item => {
if (item.data.tags) { // handle pages that don't have tags if (item.data.tags) { // handle pages that don't have tags
item.data.tags.map(tag => { item.data.tags.map(tag => {
if (tag != "post"){ if (tag != "post") {
tagsList.add(tag) tagsList.add(tag)
} }
}) })
@ -40,42 +40,42 @@ module.exports = function (eleventyConfig) {
}); });
// clean and inline all css files // clean and inline all css files
eleventyConfig.addFilter("cssmin", function(code) { eleventyConfig.addFilter("cssmin", function (code) {
return new cleancss({}).minify(code).styles; return new cleancss({}).minify(code).styles;
}); });
// // the below three configs allow for excluding files from builds using draft: true // // the below three configs allow for excluding files from builds using draft: true
// // https://www.11ty.dev/docs/quicktips/draft-posts/ // // https://www.11ty.dev/docs/quicktips/draft-posts/
// When `permalink` is false, the file is not written to disk // When `permalink` is false, the file is not written to disk
eleventyConfig.addGlobalData("eleventyComputed.permalink", function() { eleventyConfig.addGlobalData("eleventyComputed.permalink", function () {
return (data) => { return (data) => {
// Always skip during non-watch/serve builds // Always skip during non-watch/serve builds
if(data.draft && !process.env.BUILD_DRAFTS) { if (data.draft && !process.env.BUILD_DRAFTS) {
return false; return false;
} }
return data.permalink; return data.permalink;
} }
}); });
// When `eleventyExcludeFromCollections` is true, the file is not included in any collections // When `eleventyExcludeFromCollections` is true, the file is not included in any collections
eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", function() { eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", function () {
return (data) => { return (data) => {
// Always exclude from non-watch/serve builds // Always exclude from non-watch/serve builds
if(data.draft && !process.env.BUILD_DRAFTS) { if (data.draft && !process.env.BUILD_DRAFTS) {
return true; return true;
} }
return data.eleventyExcludeFromCollections; return data.eleventyExcludeFromCollections;
} }
}); });
eleventyConfig.on("eleventy.before", ({runMode}) => { eleventyConfig.on("eleventy.before", ({ runMode }) => {
// Set the environment variable // Set the environment variable
if(runMode === "serve" || runMode === "watch") { if (runMode === "serve" || runMode === "watch") {
process.env.BUILD_DRAFTS = true; process.env.BUILD_DRAFTS = true;
} }
}); });
return { return {
passthroughFileCopy: true, passthroughFileCopy: true,