// Drafts are visible on the dev server and nowhere else. // // ELEVENTY_RUN_MODE is "serve" or "watch" under `yarn dev`, and "build" under // `yarn build` — which is the only thing CI and the Dockerfile ever run. So the // gate fails safe: a draft can be previewed at its real permalink locally, but // no code path that produces a deployable _site/ will emit one. // // Collection membership is itself gated on the run mode, and that is the hard // guarantee rather than a courtesy: // // build — a draft belongs to NO collection, so no template can render its // title, date, or URL even by accident. Eleventy auto-creates a // collection per tag, and drafts carry `tags: [column, ]` // so that promoting one is a plain `git mv`. That means they land // in collections.philosophy and friends, which /subjects/ iterates // directly — it listed every draft with href="false" until this // gate existed. Filtering the two hand-written collections was not // enough; only excluding them wholesale is. // serve — a draft joins collections so /drafts/ can enumerate them. The // `draft` flag then keeps them out of the homepage and the sidebar // (see .eleventy.js) and out of /subjects/ (see subjects.njk), so // every page except /drafts/ shows exactly what production shows. // // Promoting a draft is `git mv drafts/x.md columns/`: the front matter is // already complete and correct, and leaving this directory is what publishes it. const PREVIEW = process.env.ELEVENTY_RUN_MODE !== "build"; module.exports = { draft: true, eleventyExcludeFromCollections: !PREVIEW, eleventyComputed: { permalink: (data) => (PREVIEW ? data.permalink : false), }, };