add drafting functionality and test
This commit is contained in:
37
.eleventy.js
37
.eleventy.js
@ -3,6 +3,7 @@ const rimraf = require("rimraf");
|
|||||||
const cleancss = require("clean-css");
|
const cleancss = require("clean-css");
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
|
// delete contents of public to ensure removed files are removed from the final build
|
||||||
rimraf.windows.sync("public/")
|
rimraf.windows.sync("public/")
|
||||||
|
|
||||||
eleventyConfig.addPassthroughCopy("./src/_assets/css");
|
eleventyConfig.addPassthroughCopy("./src/_assets/css");
|
||||||
@ -10,6 +11,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
eleventyConfig.addPassthroughCopy("./src/_assets/fonts");
|
eleventyConfig.addPassthroughCopy("./src/_assets/fonts");
|
||||||
eleventyConfig.addPassthroughCopy("./src/_assets/js");
|
eleventyConfig.addPassthroughCopy("./src/_assets/js");
|
||||||
|
|
||||||
|
// make a list of all tags besides "post" and add them to the collection
|
||||||
eleventyConfig.addCollection("tagsList", function (collectionApi) {
|
eleventyConfig.addCollection("tagsList", function (collectionApi) {
|
||||||
const tagsList = new Set();
|
const tagsList = new Set();
|
||||||
collectionApi.getAll().map(item => {
|
collectionApi.getAll().map(item => {
|
||||||
@ -24,6 +26,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
return tagsList;
|
return tagsList;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// minify all html files
|
||||||
eleventyConfig.addTransform("htmlmin", function (content) {
|
eleventyConfig.addTransform("htmlmin", function (content) {
|
||||||
if (this.page.outputPath && this.page.outputPath.endsWith(".html")) {
|
if (this.page.outputPath && this.page.outputPath.endsWith(".html")) {
|
||||||
let minified = htmlmin.minify(content, {
|
let minified = htmlmin.minify(content, {
|
||||||
@ -36,10 +39,44 @@ module.exports = function (eleventyConfig) {
|
|||||||
return content;
|
return content;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// // https://www.11ty.dev/docs/quicktips/draft-posts/
|
||||||
|
// When `permalink` is false, the file is not written to disk
|
||||||
|
eleventyConfig.addGlobalData("eleventyComputed.permalink", function() {
|
||||||
|
return (data) => {
|
||||||
|
// Always skip during non-watch/serve builds
|
||||||
|
if(data.draft && !process.env.BUILD_DRAFTS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.permalink;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// When `eleventyExcludeFromCollections` is true, the file is not included in any collections
|
||||||
|
eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", function() {
|
||||||
|
return (data) => {
|
||||||
|
// Always exclude from non-watch/serve builds
|
||||||
|
if(data.draft && !process.env.BUILD_DRAFTS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.eleventyExcludeFromCollections;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
eleventyConfig.on("eleventy.before", ({runMode}) => {
|
||||||
|
// Set the environment variable
|
||||||
|
if(runMode === "serve" || runMode === "watch") {
|
||||||
|
process.env.BUILD_DRAFTS = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
passthroughFileCopy: true,
|
passthroughFileCopy: true,
|
||||||
dir: {
|
dir: {
|
||||||
|
17
src/blog/blog_next.md
Normal file
17
src/blog/blog_next.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: blog_next
|
||||||
|
# eleventyExcludeFromCollections: true
|
||||||
|
# permalink: false
|
||||||
|
draft: true
|
||||||
|
---
|
||||||
|
|
||||||
|
- megatabbing habits
|
||||||
|
|
||||||
|
- smsl c200
|
||||||
|
|
||||||
|
- https://www.11ty.dev/docs/quicktips/not-found/
|
||||||
|
|
||||||
|
- insane synths https://www.lovehulten.com/
|
||||||
|
|
||||||
|
- https://www.youtube.com/watch?v=fUyQEPzpkLk
|
||||||
|
- i have an immense need for these delightful little cardboard containers, even though i dont really have anythign to put in them
|
Reference in New Issue
Block a user