Eleventy Plugin Baseline

A magic carpet ride

Table of Contents

Baseline plugin reference

Reference walkthrough of the Baseline plugin. This mirrors @apleasantview/eleventy-plugin-baseline/eleventy.config.js in code order.

Purpose

  • Defines the Baseline plugin (options, modules, filters/shortcodes) and exports the Eleventy config defaults (baselineConfig).

Version check and options

  • versionCheck(">=3.0") warns if Eleventy is too old.
  • userOptions defaults:
    • verbose (false), enableNavigatorTemplate (false), enableSitemapTemplate (true)
    • assets.esbuild ({ minify: true, target: "es2020" })
    • multilingual (false), defaultLanguage, languages (required when multilingual is on)
    • Tracks hasImageTransformPlugin
  • Multilang guard: requires defaultLanguage + non-empty languages map.
  • filterAllCollection (true): when enabled, Baseline attempts to filter out *.11tydata.js items from collections.all. This is a side-effect of assets-esbuild.

Globals, passthrough, drafts

  • Adds global _baseline with resolved options.
  • Passthrough copy: ./src/static/.
  • Draft preprocessor: skips draft: true when ELEVENTY_RUN_MODE === "build"; you can override this in your own config if needed.

Modules registered

  • HtmlBasePlugin: baseHref from process.env.URL or pathPrefix.
  • Assets: assets-core, assets-postcss, assets-esbuild (with assets.esbuild options).
  • Head: head-core (enables <baseline-head>).
  • Sitemap: sitemap-core (template on by default; multilingual-aware).
  • Navigator: navigator-core (debugging template (off by default) and debug globals).
  • Multilang: multilang-core when multilingual is true and languages provided.

Filters, shortcodes, debug

  • Filters: markdownify, relatedPosts, isString.
  • Debug filters: _inspect, _json, _keys.
  • Shortcode: image.

Dev server

  • Adds eleventyImageOnRequestDuringServePlugin for on-request image generation during serve.

Plugin metadata

  • Sets plugin.name explicitly to @apleasantview/eleventy-plugin-baseline so eleventyConfig.hasPlugin() can detect it.

Exported config defaults

export const config = {
	dir: {
		input: 'src',
		output: 'dist',
		data: '_data',
		includes: '_includes',
		assets: 'assets'
	},
	htmlTemplateEngine: 'njk',
	markdownTemplateEngine: 'njk',
	templateFormats: ['html', 'njk', 'md']
};

Not included

  • HTML image transform plugin (eleventyImageTransformPlugin) wiring; add it yourself if you need content-level <img> rewrites.

Customize safely

  • Start from baselineConfig and merge if you change dirs/engines/formats so assets/head/sitemap continue to work.

Previous: References

Next: Plugin entrypoint