@sveti/ba1-config 0.0.0-stage → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,145 @@
1
+ //<!--section:code-->```js
2
+
3
+ /* Plugins (core > official > contrib) */
4
+ import { RenderPlugin } from "@11ty/eleventy";
5
+ import { feedPlugin } from "@11ty/eleventy-plugin-rss";
6
+ import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
7
+ import onePlugin from "@sveti/ba1-plugin";
8
+ import { siteData } from "@sveti/ba1-plugin/features/siteData.js";
9
+ import pluginTOC from "@uncenter/eleventy-plugin-toc";
10
+ /* Libraries (A-Z) */
11
+ import { load as loadYaml } from "js-yaml";
12
+ import markdownIt from "markdown-it";
13
+ import markdownItAnchor from "markdown-it-anchor";
14
+ import markdownItAttrs from "markdown-it-attrs";
15
+ import slugify from "@sindresorhus/slugify";
16
+ /* System (A-Z) */
17
+ import fs from "node:fs";
18
+ import path from "node:path";
19
+
20
+ /**
21
+ * Eleventy Configuration
22
+ * @param {Object} $config - The Eleventy configuration object
23
+ * @returns {Object} The Eleventy configuration object
24
+ */
25
+ export default async function ($config, pluginOptions = {}) {
26
+ /* Dirs */
27
+ const inputDir = $config.directories.input;
28
+ const outputDir = $config.directories.output;
29
+ const _cwd = path.basename(process.cwd());
30
+ const cwdDotDir = _cwd.startsWith(".") ? _cwd : undefined;
31
+ if (cwdDotDir) {
32
+ // Per https://www.11ty.dev/docs/config/#directory-for-includes
33
+ // Order matters, put this at the top of your configuration file.
34
+ // This is relative to your input directory!
35
+ $config.setIncludesDirectory(`${cwdDotDir}/_includes/`);
36
+ }
37
+
38
+ /* Plugins */
39
+ $config.addBundle("css", { bundleHtmlContentFromSelector: "style" }); // per https://www.11ty.dev/docs/plugins/bundle/#bundling-html-node-content
40
+ $config.addTransform("inject-css-bundle", function (content) {
41
+ const isHtml = typeof this.page.outputPath === "string" && this.page.outputPath.endsWith(".html");
42
+ const css = isHtml && $config.getFilter("getBundle").call(this, "css");
43
+ return css ? content.replace("</head>", `<style>${css}</style></head>`) : content;
44
+ });
45
+ $config.addPlugin(RenderPlugin);
46
+ $config.addPlugin(eleventyNavigationPlugin);
47
+ $config.addPlugin(onePlugin, pluginOptions.plugins?.["@sveti/ba1-plugin"] ?? { mdAutoRawTags: true });
48
+ $config.addPlugin(pluginTOC, {
49
+ ignoredElements: [".header-anchor", "sub"],
50
+ ul: true,
51
+ wrapper: (toc) => `${toc}`,
52
+ });
53
+ // Feed plugin
54
+ $config.addCollection("feed", (collectionApi) =>
55
+ collectionApi.getAll().filter((item) => item.data.date || item.data.revised),
56
+ );
57
+ $config.addPlugin(feedPlugin, {
58
+ // per https://www.11ty.dev/docs/plugins/rss/#virtual-template
59
+ type: "atom", // or "rss", "json"
60
+ outputPath: "/feed.xml",
61
+ collection: {
62
+ name: "feed",
63
+ limit: 100, // 0 means no limit
64
+ },
65
+ templateData: {
66
+ eleventyComputed: {
67
+ metadata: (data) => {
68
+ return {
69
+ base: "https://example.com/", // sample/fallback value required by Feed plugin
70
+ ...siteData(data),
71
+ };
72
+ },
73
+ },
74
+ },
75
+ });
76
+
77
+ /* Libraries */
78
+ let md = markdownIt({
79
+ html: true,
80
+ linkify: true,
81
+ })
82
+ .use(markdownItAnchor, {
83
+ slugify: slugify, // @TODO: TRICKS
84
+ permalink: markdownItAnchor.permalink.ariaHidden(),
85
+ })
86
+ .use(markdownItAttrs);
87
+ await import("markdown-it-deflist")
88
+ .then(({ default: markdownItDeflist }) => {
89
+ md.use(markdownItDeflist);
90
+ })
91
+ .catch(() => {
92
+ /* optional – skip if not installed */
93
+ });
94
+ $config.setLibrary("md", md);
95
+ //```<!--section:code,markdownify-->```js
96
+ $config.addFilter("markdownify", (content) => md.render(String(content ?? "")));
97
+ //```<!--section:code-->```js
98
+
99
+ /* Data */
100
+ $config.addDataExtension("yml,yaml", (contents) => loadYaml(contents));
101
+ $config.addGlobalData("layout", "default");
102
+ // Sitemap
103
+ $config.addTemplate("sitemap.xml.njk", "", {
104
+ permalink: "/sitemap.xml",
105
+ layout: "blades/sitemap.xml.njk",
106
+ eleventyExcludeFromCollections: true,
107
+ });
108
+
109
+ /* Build */
110
+ $config.addPassthroughCopy(
111
+ {
112
+ // From current working directory
113
+ "_public/": "/",
114
+ "media/": "/media/",
115
+ // Additionally from input dirs like `../` or `./site-1`
116
+ [`${inputDir}/_public/`]: "/",
117
+ [`${inputDir}/media/`]: "/media/",
118
+ },
119
+ { expand: true }, // This follows/resolves symbolic links
120
+ );
121
+
122
+ /* Internal */
123
+ // Jekyll templates compatibility
124
+ $config.addFilter("relative_url", (content) => content); // dummy
125
+ $config.setLiquidOptions({
126
+ dynamicPartials: false, // allows unquoted Jekyll-style includes
127
+ root: [
128
+ $config.directories.includes,
129
+ // for symlinks to work after https://github.com/harttle/liquidjs/pull/870 (optional: skipped if node_modules absent)
130
+ ...(fs.existsSync("node_modules/@sveti/blades/_includes")
131
+ ? [fs.realpathSync(path.resolve("node_modules/@sveti/blades/_includes"))]
132
+ : []),
133
+ ...(fs.existsSync("../../node_modules/@sveti/blades/_includes")
134
+ ? [fs.realpathSync(path.resolve("../../node_modules/@sveti/blades/_includes"))]
135
+ : []),
136
+ ],
137
+ });
138
+ // Dev tools
139
+ $config.setChokidarConfig({ followSymlinks: true }); // follow symlinks in Chokidar used by 11ty to watch files
140
+ if (cwdDotDir) {
141
+ $config.watchIgnores.add(`../${cwdDotDir}/${outputDir}`); // !!! avoid circular watching
142
+ $config.watchIgnores.add(`../${cwdDotDir}/node_modules/`); // avoid performance issues
143
+ }
144
+ }
145
+ //```
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@sveti/ba1-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.5.5",
4
+ "type": "module",
5
+ "main": "./buildawesome.config.js",
6
+ "dependencies": {
7
+ "@11ty/eleventy-navigation": "^1.0.5",
8
+ "@11ty/eleventy-plugin-rss": "^3.1.0",
9
+ "@sveti/ba1-cli": "^1.5.1",
10
+ "@sveti/ba1-plugin": "^1.5.1",
11
+ "@sveti/blades": "^3.1.4",
12
+ "@uncenter/eleventy-plugin-toc": "^2.1.2",
13
+ "markdown-it": "^15.0.3",
14
+ "markdown-it-anchor": "^10.1.0",
15
+ "markdown-it-attrs": "^5.0.1"
16
+ },
17
+ "peerDependencies": {
18
+ "@11ty/eleventy": "^3.0.0 || ^4.0.0-0",
19
+ "@awesome.me/buildawesome": "^4.0.0-0"
20
+ },
21
+ "peerDependenciesMeta": {
22
+ "@11ty/eleventy": {
23
+ "optional": true
24
+ },
25
+ "@awesome.me/buildawesome": {
26
+ "optional": true
27
+ }
28
+ },
29
+ "--- METADATA": "---",
30
+ "author": "Anton Staroverov",
31
+ "homepage": "https://buildawesome.one/config/",
32
+ "keywords": [
33
+ "11ty",
34
+ "buildawesome",
35
+ "buildawesome-one",
36
+ "eleventy",
37
+ "config"
38
+ ],
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/open-sveti/ba1.git",
43
+ "directory": "config/"
44
+ },
45
+ "---": "---"
46
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.