Skip to content

Instantly share code, notes, and snippets.

@Zearin
Last active March 9, 2024 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zearin/fc3c20075857c9a54dff569832cbea55 to your computer and use it in GitHub Desktop.
Save Zearin/fc3c20075857c9a54dff569832cbea55 to your computer and use it in GitHub Desktop.

Config objects

  • Config classes.
  • eleventyConfig.
    • Many class constructors and methods accept an eleventyConfig argument.
    • In Eleventy.initializeConfig(), this is a TemplateConfig instance.
    • A TemplateConfig instance holds a reference to a UserConfig instance. If I understand correctly, this is so that a user’s configuration can be tweaked on a template-by-template basis. Is this correct?
  • “Config” vs. “options”.
    • When a class handles both “config” and “options”, what distinguishes whether a setting falls into one category or another?
  • Total configuration awareness®.
    • Are there any other types of config?
    • What makes their roles different?
    • Which ones override others (and in which circumstances)?

Eleventy constructor signatures

In Getting to know the Eleventy 3 codebase, I started to try and become familiar with the many moving parts of the awesome Eleventy project.

I’m trying to take a project-wide view and compare bits of code in order to learn how everything works.

Here, I’ve collected the signatures of every constructor in order to look at them side-by-side and see what I notice.

// src/Benchmark.js:
class Benchmark { constructor() {} }

// src/BenchmarkGroup.js:
class BenchmarkGroup { constructor() {} }

// src/BenchmarkManager.js:
class BenchmarkManager { constructor() {} }

// src/ComputedData.js:
class ComputedData {
	constructor(config) {}
}

// src/ComputedDataProxy.js:
class ComputedDataProxy {
	constructor(computedKeys) {}
}

// src/ComputedDataQueue.js:
class ComputedDataQueue { constructor() {} }

// src/ComputedDataTemplateString.js:
class ComputedDataTemplateString {
	constructor(computedKeys) {}
}

// src/Eleventy.js:
class Eleventy {
	constructor(input, output, options = {}, eleventyConfig = null) {}
}

// src/EleventyBaseError.js:
class EleventyBaseError {
	constructor(message, originalError) {}
}

// src/EleventyErrorHandler.js:
class EleventyErrorHandler { constructor() {} }

// src/EleventyExtensionMap.js:
class EleventyExtensionMap {
	constructor(formatKeys, config) {}
}

// src/EleventyFiles.js:
class EleventyFiles {
	constructor(input, outputDir, formats, eleventyConfig) {}
}

// src/EleventyServe.js:
class EleventyServe { constructor() {} }

// src/EleventyWatch.js:
class EleventyWatch { constructor() {} }

// src/EleventyWatchTargets.js:
class EleventyWatchTargets { constructor() {} }

// src/FileSystemSearch.js:
class FileSystemSearch { constructor() {} }

// src/Template.js:
class Template extends TemplateContent {
	constructor(templatePath, inputDir, outputDir, templateData, extensionMap, config) {}
}

// src/TemplateBehavior.js:
class TemplateBehavior {
	constructor(config) {}
}

// src/TemplateCache.js:
class TemplateCache { constructor() {} }

// src/TemplateCollection.js:
class TemplateCollection extends Sortable { constructor() {} }

// src/TemplateConfig.js:
class TemplateConfig {
	constructor(customRootConfig, projectConfigPath) {}
}

// src/TemplateContent.js:
class TemplateContent {
	constructor(inputPath, inputDir, config) {}
}

// src/TemplateData.js:
class TemplateData {
	constructor(inputDir, eleventyConfig) {}
}

// src/TemplateDataInitialGlobalData.js:
class TemplateDataInitialGlobalData {
	constructor(templateConfig) {}
}

// src/TemplateEngineManager.js:
class TemplateEngineManager {
	constructor(eleventyConfig) {}
}

// src/TemplateFileSlug.js:
class TemplateFileSlug {
	constructor(inputPath, inputDir, extensionMap) {}
}

// src/TemplateLayout.js:
class TemplateLayout extends TemplateContent {
	constructor(key, inputDir, extensionMap, eleventyConfig) {}
}

// src/TemplateLayoutPathResolver.js:
class TemplateLayoutPathResolver {
	constructor(path, inputDir, extensionMap, eleventyConfig) {}
}

// src/TemplateMap.js:
class TemplateMap {
	constructor(eleventyConfig) {}
}

// src/TemplatePassthrough.js:
class TemplatePassthrough {
	constructor(path, outputDir, inputDir, config) {}
}

// src/TemplatePassthroughManager.js:
class TemplatePassthroughManager {
	constructor(eleventyConfig) {}
}

// src/TemplatePermalink.js:
class TemplatePermalink {  
	constructor(link, extraSubdir) {}
}


// src/TemplateRender.js:
class TemplateRender {
	constructor(tmplPath, inputDir, config) {}
}

// src/TemplateWriter.js:
class TemplateWriter {
	constructor(
		inputPath,
		outputDir,
		templateFormats, // TODO remove this, see `get eleventyFiles` first
		templateData,
		eleventyConfig,
	) {}
}

// src/UserConfig.js:
class UserConfig { constructor() {} }

// src/Engines/Custom.js:
class CustomEngine extends TemplateEngine {
	constructor(name, dirs, config) {}
}

// src/Engines/Html.js:
class Html extends TemplateEngine {
	constructor(name, dirs, config) {}
}

// src/Engines/JavaScript.js:
class JavaScript extends TemplateEngine {
	constructor(name, dirs, config) {}
}

// src/Engines/Liquid.js:
class Liquid extends TemplateEngine {
	constructor(name, dirs, config) {}
}


// src/Engines/Markdown.js:
class Markdown extends TemplateEngine {
	constructor(name, dirs, config) {}
}

// src/Engines/Nunjucks.js:
class Nunjucks extends TemplateEngine {
	constructor(name, dirs, config) {}
}

// src/Engines/TemplateEngine.js:
class TemplateEngine {
	constructor(name, dirs, eleventyConfig) {}
}

// src/Plugins/Pagination.js:
class Pagination {
	constructor(tmpl, data, config) {}
}

// src/Plugins/RenderPlugin.js:
class RenderManager { constructor() {} }

// src/Util/Compatibility.js:
class Compatibility { 
	constructor(compatibleRange) {}
}

// src/Util/ConsoleLogger.js:
class ConsoleLogger { constructor() {} }

// src/Util/ExistsCache.js:
class ExistsCache { constructor() {} }

// src/Util/HtmlTransformer.js:
class HtmlTransformer { constructor() {} }

// src/Util/Sortable.js:
class Sortable { constructor() {} }

Files & Paths

According to filenames, below is a list of all the files/classes that deal with files or paths (including “globs”). I’ll list path-related dependencies outside of the node: standard library under each one.

I’m trying to get a list of all path-related functionality here. I’m not trying to include I/O (read/write) operations. If a class does some of both, and its name implies more path-related purpose, then I’ll include it.

Here’s where you come in!

Did I miss anything?

Any observations about the above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment