@anyblades/buildawesome-kit 1.3.0-alpha → 1.3.0-alpha.3
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.
- package/README.md +11 -11
- package/{eleventy.config.js → buildawesome.config.js} +30 -29
- package/package.json +4 -4
- package/plugin/features/autoLinkFavicons.js +2 -2
- package/plugin/features/mdAutoNl2br.js +2 -2
- package/plugin/features/mdAutoRawTags.js +2 -2
- package/plugin/features/mdAutoUncommentAttrs.js +2 -2
- package/plugin/features/siteData.js +2 -2
- package/plugin/features/virtualPages.js +3 -3
- package/plugin/package.json +1 -1
- package/plugin/plugin.js +3 -3
package/README.md
CHANGED
|
@@ -39,15 +39,15 @@ Then `addPlugin` to your 11ty config:
|
|
|
39
39
|
```js
|
|
40
40
|
import eleventyBladesPlugin from "@anyblades/eleventy-blades";
|
|
41
41
|
|
|
42
|
-
export default function (
|
|
43
|
-
|
|
42
|
+
export default function ($config) {
|
|
43
|
+
$config.addPlugin(eleventyBladesPlugin);
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
You can toggle features/filters like this:
|
|
48
48
|
|
|
49
49
|
```js
|
|
50
|
-
|
|
50
|
+
$config.addPlugin(eleventyBladesPlugin, {
|
|
51
51
|
mdAutoRawTags: false,
|
|
52
52
|
filters: { attr_set: false },
|
|
53
53
|
});
|
|
@@ -93,7 +93,7 @@ cd _includes/
|
|
|
93
93
|
ln -s ../node_modules/@anyblades/blades/_includes/blades
|
|
94
94
|
|
|
95
95
|
# Run Eleventy:
|
|
96
|
-
eleventy --config=node_modules/@anyblades/eleventy-blades-base/
|
|
96
|
+
eleventy --config=node_modules/@anyblades/eleventy-blades-base/buildawesome.config.js
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Live examples:
|
|
@@ -106,7 +106,7 @@ Live examples:
|
|
|
106
106
|
If you don't want to type `--config=...` every time, symlink it once:
|
|
107
107
|
|
|
108
108
|
```sh
|
|
109
|
-
ln -s node_modules/@anyblades/eleventy-blades-base/
|
|
109
|
+
ln -s node_modules/@anyblades/eleventy-blades-base/buildawesome.config.js
|
|
110
110
|
eleventy
|
|
111
111
|
```
|
|
112
112
|
|
|
@@ -114,7 +114,7 @@ Or save it in your `package.json` scripts:
|
|
|
114
114
|
|
|
115
115
|
```json
|
|
116
116
|
"scripts": {
|
|
117
|
-
"build": "eleventy --config=node_modules/@anyblades/eleventy-blades-base/
|
|
117
|
+
"build": "eleventy --config=node_modules/@anyblades/eleventy-blades-base/buildawesome.config.js"
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
@@ -125,15 +125,15 @@ Alternatively, import it as a base config in your 11ty config:
|
|
|
125
125
|
```js
|
|
126
126
|
import baseConfig from "@anyblades/eleventy-blades-base";
|
|
127
127
|
|
|
128
|
-
export default async function (
|
|
129
|
-
await baseConfig(
|
|
128
|
+
export default async function ($config) {
|
|
129
|
+
await baseConfig($config);
|
|
130
130
|
}
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
You can toggle features/filters like this:
|
|
134
134
|
|
|
135
135
|
```js
|
|
136
|
-
await baseConfig(
|
|
136
|
+
await baseConfig($config, {
|
|
137
137
|
plugins: {
|
|
138
138
|
"@anyblades/eleventy-blades": {
|
|
139
139
|
mdAutoRawTags: false,
|
|
@@ -145,8 +145,8 @@ await baseConfig(eleventyConfig, {
|
|
|
145
145
|
|
|
146
146
|
Live examples:
|
|
147
147
|
|
|
148
|
-
- https://github.com/johnheenan/minform/blob/main/
|
|
149
|
-
- https://github.com/hostfurl/minformhf/blob/main/
|
|
148
|
+
- https://github.com/johnheenan/minform/blob/main/buildawesome.config.js
|
|
149
|
+
- https://github.com/hostfurl/minformhf/blob/main/buildawesome.config.js
|
|
150
150
|
|
|
151
151
|
<!--section:gh-only-->
|
|
152
152
|
|
|
@@ -19,44 +19,45 @@ import path from "node:path";
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Eleventy Configuration
|
|
22
|
-
* @param {Object}
|
|
22
|
+
* @param {Object} $config - The Eleventy configuration object
|
|
23
23
|
* @returns {Object} The Eleventy configuration object
|
|
24
24
|
*/
|
|
25
|
-
export default async function (
|
|
25
|
+
export default async function ($config, pluginOptions = {}) {
|
|
26
26
|
/* Dirs */
|
|
27
|
-
const inputDir =
|
|
28
|
-
const outputDir =
|
|
29
|
-
const
|
|
30
|
-
|
|
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) {
|
|
31
32
|
// Per https://www.11ty.dev/docs/config/#directory-for-includes
|
|
32
33
|
// Order matters, put this at the top of your configuration file.
|
|
33
34
|
// This is relative to your input directory!
|
|
34
|
-
|
|
35
|
+
$config.setIncludesDirectory(`${cwdDotDir}/_includes/`);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/* Plugins */
|
|
38
|
-
|
|
39
|
-
|
|
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) {
|
|
40
41
|
const isHtml = typeof this.page.outputPath === "string" && this.page.outputPath.endsWith(".html");
|
|
41
|
-
const css = isHtml &&
|
|
42
|
+
const css = isHtml && $config.getFilter("getBundle").call(this, "css");
|
|
42
43
|
return css ? content.replace("</head>", `<style>${css}</style></head>`) : content;
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
$config.addPlugin(RenderPlugin);
|
|
46
|
+
$config.addPlugin(eleventyNavigationPlugin);
|
|
47
|
+
$config.addPlugin(
|
|
47
48
|
kitPlugin,
|
|
48
49
|
pluginOptions.plugins?.["@anyblades/buildawesome-kit-plugin"] ?? { mdAutoRawTags: true },
|
|
49
50
|
);
|
|
50
|
-
|
|
51
|
+
$config.addPlugin(pluginTOC, {
|
|
51
52
|
ignoredElements: [".header-anchor", "sub"],
|
|
52
53
|
ul: true,
|
|
53
54
|
wrapper: (toc) => `${toc}`,
|
|
54
55
|
});
|
|
55
56
|
// Feed plugin
|
|
56
|
-
|
|
57
|
+
$config.addCollection("feed", (collectionApi) =>
|
|
57
58
|
collectionApi.getAll().filter((item) => item.data.date || item.data.revised),
|
|
58
59
|
);
|
|
59
|
-
|
|
60
|
+
$config.addPlugin(feedPlugin, {
|
|
60
61
|
// per https://www.11ty.dev/docs/plugins/rss/#virtual-template
|
|
61
62
|
type: "atom", // or "rss", "json"
|
|
62
63
|
outputPath: "/feed.xml",
|
|
@@ -93,23 +94,23 @@ export default async function (eleventyConfig, pluginOptions = {}) {
|
|
|
93
94
|
.catch(() => {
|
|
94
95
|
/* optional – skip if not installed */
|
|
95
96
|
});
|
|
96
|
-
|
|
97
|
+
$config.setLibrary("md", md);
|
|
97
98
|
//```<!--section:code,markdownify-->```js
|
|
98
|
-
|
|
99
|
+
$config.addFilter("markdownify", (content) => md.render(String(content ?? "")));
|
|
99
100
|
//```<!--section:code-->```js
|
|
100
101
|
|
|
101
102
|
/* Data */
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
$config.addDataExtension("yml,yaml", (contents) => YAML.parse(contents));
|
|
104
|
+
$config.addGlobalData("layout", "default");
|
|
104
105
|
// Sitemap
|
|
105
|
-
|
|
106
|
+
$config.addTemplate("sitemap.xml.njk", "", {
|
|
106
107
|
permalink: "/sitemap.xml",
|
|
107
108
|
layout: "blades/sitemap.xml.njk",
|
|
108
109
|
eleventyExcludeFromCollections: true,
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
/* Build */
|
|
112
|
-
|
|
113
|
+
$config.addPassthroughCopy(
|
|
113
114
|
{
|
|
114
115
|
// From current working directory
|
|
115
116
|
_public: "./",
|
|
@@ -123,19 +124,19 @@ export default async function (eleventyConfig, pluginOptions = {}) {
|
|
|
123
124
|
|
|
124
125
|
/* Internal */
|
|
125
126
|
// Jekyll templates compatibility
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
$config.addFilter("relative_url", (content) => content); // dummy
|
|
128
|
+
$config.setLiquidOptions({
|
|
128
129
|
dynamicPartials: false, // allows unquoted Jekyll-style includes
|
|
129
130
|
root: [
|
|
130
|
-
|
|
131
|
+
$config.directories.includes,
|
|
131
132
|
fs.realpathSync(path.resolve("./node_modules/@anyblades/blades/_includes")), // for symlinks to work after https://github.com/harttle/liquidjs/pull/870
|
|
132
133
|
],
|
|
133
134
|
});
|
|
134
135
|
// Dev tools
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
$config.setChokidarConfig({ followSymlinks: true }); // follow symlinks in Chokidar used by 11ty to watch files
|
|
137
|
+
if (cwdDotDir) {
|
|
138
|
+
$config.watchIgnores.add(`../${cwdDotDir}/${outputDir}`); // !!! avoid circular watching
|
|
139
|
+
$config.watchIgnores.add(`../${cwdDotDir}/node_modules/`); // avoid performance issues
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
//```
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyblades/buildawesome-kit",
|
|
3
|
-
"version": "1.3.0-alpha",
|
|
3
|
+
"version": "1.3.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./buildawesome.config.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@11ty/eleventy-navigation": "^1.0.5",
|
|
8
8
|
"@11ty/eleventy-plugin-rss": "^3.0.0",
|
|
9
9
|
"@anyblades/blades": "^2.4.6",
|
|
10
|
-
"@anyblades/buildawesome-kit-plugin": "^1.3.0-
|
|
10
|
+
"@anyblades/buildawesome-kit-plugin": "^1.3.0-alpha.2",
|
|
11
11
|
"@uncenter/eleventy-plugin-toc": "^2.1.1",
|
|
12
12
|
"markdown-it": "^14.1.0",
|
|
13
13
|
"markdown-it-anchor": "^9.2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"=== METADATA": "===",
|
|
34
34
|
"author": "Anton Staroverov",
|
|
35
|
-
"description": "A ready-to-go `
|
|
35
|
+
"description": "A ready-to-go `buildawesome.config.js` for popular 11ty plugins, bundled with npm scripts in one reusable, zero-maintenance package.",
|
|
36
36
|
"homepage": "https://build.blades.ninja/",
|
|
37
37
|
"keywords": [
|
|
38
38
|
"11ty",
|
|
@@ -60,8 +60,8 @@ export function replaceLinksInHtml(content, transformer) {
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export default function (
|
|
64
|
-
|
|
63
|
+
export default function ($config) {
|
|
64
|
+
$config.addTransform("autoLinkFavicons", function (content) {
|
|
65
65
|
if (this.page.outputPath && this.page.outputPath.endsWith(".html")) {
|
|
66
66
|
return replaceLinksInHtml(content, transformLink);
|
|
67
67
|
}
|
|
@@ -12,8 +12,8 @@ export function transformNl2br(content) {
|
|
|
12
12
|
return content.replace(/\\n\\n/g, "<br>").replace(/\\n/g, "<br>");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export default function mdAutoNl2br(
|
|
16
|
-
|
|
15
|
+
export default function mdAutoNl2br($config) {
|
|
16
|
+
$config.amendLibrary("md", (mdLib) => {
|
|
17
17
|
mdLib.renderer.rules.text = (tokens, idx) => {
|
|
18
18
|
return transformNl2br(tokens[idx].content);
|
|
19
19
|
};
|
|
@@ -9,8 +9,8 @@ export function transformAutoRaw(content) {
|
|
|
9
9
|
return content.replace(/({{|}}|{%|%})/g, "{% raw %}$1{% endraw %}");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export default function mdAutoRawTags(
|
|
13
|
-
|
|
12
|
+
export default function mdAutoRawTags($config) {
|
|
13
|
+
$config.addPreprocessor("mdAutoRawTags", "md", (data, content) => {
|
|
14
14
|
return transformAutoRaw(content);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -16,8 +16,8 @@ export function transformUncommentAttrs(content) {
|
|
|
16
16
|
return content;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export default function mdAutoUncommentAttrs(
|
|
20
|
-
|
|
19
|
+
export default function mdAutoUncommentAttrs($config) {
|
|
20
|
+
$config.amendLibrary("md", (mdLib) => {
|
|
21
21
|
mdLib.core.ruler.before("normalize", "uncomment_attrs", (state) => {
|
|
22
22
|
state.src = transformUncommentAttrs(state.src);
|
|
23
23
|
});
|
|
@@ -31,8 +31,8 @@ export const siteData = (data) => {
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export default function (
|
|
35
|
-
|
|
34
|
+
export default function ($config) {
|
|
35
|
+
$config.addGlobalData("eleventyComputed", {
|
|
36
36
|
site: (data) => ({
|
|
37
37
|
...siteData(data),
|
|
38
38
|
prod: process.env.ELEVENTY_RUN_MODE === "build",
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import { readFileSync } from "fs";
|
|
7
7
|
import YAML from "js-yaml";
|
|
8
8
|
|
|
9
|
-
export default function (
|
|
9
|
+
export default function ($config) {
|
|
10
10
|
// Virtual pages
|
|
11
|
-
const pages = YAML.load(readFileSync(
|
|
11
|
+
const pages = YAML.load(readFileSync($config.directories.input + "/pages.yaml", "utf8"));
|
|
12
12
|
for (const [index, data] of pages.entries()) {
|
|
13
13
|
const virtualSlug = data.permalink ? data.permalink + "index" : index;
|
|
14
14
|
// console.log(data, virtualSlug);
|
|
15
|
-
|
|
15
|
+
$config.addTemplate("." + virtualSlug + ".md", "", data);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
//```
|
package/plugin/package.json
CHANGED
package/plugin/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ export const discoverModules = (dir) =>
|
|
|
8
8
|
.map((f) => [f.replace(/\.js$/, ""), true]),
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
-
export default async function (
|
|
11
|
+
export default async function ($config, userOptions) {
|
|
12
12
|
//```<!--section:code,def-options-->```js
|
|
13
13
|
const defaultOptions = { mdAutoRawTags: false };
|
|
14
14
|
//```<!--section:code-->```js
|
|
@@ -31,7 +31,7 @@ export default async function (eleventyConfig, userOptions) {
|
|
|
31
31
|
try {
|
|
32
32
|
if (filterName == "fetch") await import("@11ty/eleventy-fetch");
|
|
33
33
|
const filterFunc = (await import("./filters/" + filterName + ".js")).default;
|
|
34
|
-
|
|
34
|
+
$config.addFilter(filterName, filterFunc);
|
|
35
35
|
} catch (error) {
|
|
36
36
|
console.log("^ N/A ^");
|
|
37
37
|
}
|
|
@@ -44,7 +44,7 @@ export default async function (eleventyConfig, userOptions) {
|
|
|
44
44
|
console.log("Loading feature: " + featureName + "...");
|
|
45
45
|
try {
|
|
46
46
|
const featureConfig = (await import("./features/" + featureName + ".js")).default;
|
|
47
|
-
featureConfig(
|
|
47
|
+
featureConfig($config);
|
|
48
48
|
} catch (error) {
|
|
49
49
|
console.log("^ N/A ^");
|
|
50
50
|
}
|