fix drafts
This commit is contained in:
parent
20d6c4eef7
commit
2dbf6d816b
3 changed files with 28 additions and 57 deletions
19
content/blog/draft.md
Normal file
19
content/blog/draft.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
date: 2024-12-05
|
||||
title: draft
|
||||
description: A can opener is a service component that affords access to preserved fruits and vegetables.
|
||||
tags:
|
||||
- language
|
||||
- programming
|
||||
draft: true
|
||||
---
|
||||
|
||||
If I ask you what a can opener is, and you say
|
||||
|
||||
> A can opener is a service component that affords access to preserved fruits and vegetables.
|
||||
|
||||
This does not help me at all. I am looking for something along the lines of
|
||||
|
||||
> A can opener is a handheld metal tool that cuts the lids off of canned food, which you can buy at the grocery store. You use it by turning a knob, which puts pressure on two blades, which cut through the metal lid of the can.
|
||||
|
||||
Thank you.
|
|
@ -1,52 +0,0 @@
|
|||
function eleventyComputedPermalink() {
|
||||
// When using `addGlobalData` and you *want* to return a function, you must nest functions like this.
|
||||
// `addGlobalData` acts like a global data file and runs the top level function it receives.
|
||||
return (data) => {
|
||||
// Always skip during non-watch/serve builds
|
||||
if(data.draft && !process.env.BUILD_DRAFTS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return data.permalink;
|
||||
}
|
||||
};
|
||||
|
||||
function eleventyComputedExcludeFromCollections() {
|
||||
// When using `addGlobalData` and you *want* to return a function, you must nest functions like this.
|
||||
// `addGlobalData` acts like a global data file and runs the top level function it receives.
|
||||
return (data) => {
|
||||
// Always exclude from non-watch/serve builds
|
||||
if(data.draft && !process.env.BUILD_DRAFTS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return data.eleventyExcludeFromCollections;
|
||||
}
|
||||
};
|
||||
|
||||
const _eleventyComputedPermalink = eleventyComputedPermalink;
|
||||
export { _eleventyComputedPermalink as eleventyComputedPermalink };
|
||||
const _eleventyComputedExcludeFromCollections = eleventyComputedExcludeFromCollections;
|
||||
export { _eleventyComputedExcludeFromCollections as eleventyComputedExcludeFromCollections };
|
||||
|
||||
export default eleventyConfig => {
|
||||
eleventyConfig.addGlobalData("eleventyComputed.permalink", eleventyComputedPermalink);
|
||||
eleventyConfig.addGlobalData("eleventyComputed.eleventyExcludeFromCollections", eleventyComputedExcludeFromCollections);
|
||||
|
||||
let logged = false;
|
||||
eleventyConfig.on("eleventy.before", ({runMode}) => {
|
||||
let text = "Excluding";
|
||||
// Only show drafts in serve/watch modes
|
||||
if(runMode === "serve" || runMode === "watch") {
|
||||
process.env.BUILD_DRAFTS = true;
|
||||
text = "Including";
|
||||
}
|
||||
|
||||
// Only log once.
|
||||
if(!logged) {
|
||||
console.log( `[11ty/eleventy-base-blog] ${text} drafts.` );
|
||||
}
|
||||
|
||||
logged = true;
|
||||
});
|
||||
}
|
|
@ -3,15 +3,22 @@ import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
|||
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
|
||||
import pluginRss from '@11ty/eleventy-plugin-rss';
|
||||
|
||||
import pluginDrafts from "./eleventy.config.drafts.js";
|
||||
|
||||
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
||||
export default function(eleventyConfig) {
|
||||
console.log(process.env);
|
||||
|
||||
if (process.env.NODE_ENV === 'localhost') {
|
||||
console.log('metadata override');
|
||||
eleventyConfig.addGlobalData('metadata.url', 'http://localhost:8080');
|
||||
}
|
||||
|
||||
// Drafts
|
||||
eleventyConfig.addPreprocessor('drafts', '*', (data) => {
|
||||
if (data.draft && process.env.ELEVENTY_RUN_MODE === 'build') {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
eleventyConfig.addPassthroughCopy("content/**/*.png");
|
||||
eleventyConfig.addPassthroughCopy("content/**/*.webp");
|
||||
eleventyConfig.addPassthroughCopy('content/**/*.css');
|
||||
|
@ -24,9 +31,6 @@ export default function(eleventyConfig) {
|
|||
// Watch content images for the image pipeline.
|
||||
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpeg}");
|
||||
|
||||
// App plugins
|
||||
eleventyConfig.addPlugin(pluginDrafts);
|
||||
|
||||
// Official plugins
|
||||
eleventyConfig.addBundle('css');
|
||||
eleventyConfig.addPlugin(pluginSyntaxHighlight, {
|
||||
|
|
Loading…
Reference in a new issue