@anyblades/buildawesome-kit-plugin 1.3.0-alpha
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/features/autoLinkFavicons.js +71 -0
- package/features/autoLinkFavicons.test.js +694 -0
- package/features/mdAutoNl2br.js +22 -0
- package/features/mdAutoNl2br.test.js +68 -0
- package/features/mdAutoRawTags.js +17 -0
- package/features/mdAutoRawTags.test.js +80 -0
- package/features/mdAutoUncommentAttrs.js +26 -0
- package/features/mdAutoUncommentAttrs.test.js +65 -0
- package/features/siteData.js +43 -0
- package/features/siteData.test.js +120 -0
- package/features/virtualPages.js +18 -0
- package/filters/attr_concat.js +55 -0
- package/filters/attr_concat.test.js +205 -0
- package/filters/attr_includes.js +41 -0
- package/filters/attr_includes.test.js +125 -0
- package/filters/attr_set.js +22 -0
- package/filters/attr_set.test.js +71 -0
- package/filters/date.js +11 -0
- package/filters/date.test.js +33 -0
- package/filters/fetch.js +80 -0
- package/filters/if.js +24 -0
- package/filters/if.test.js +63 -0
- package/filters/merge.js +51 -0
- package/filters/merge.test.js +51 -0
- package/filters/remove_tag.js +42 -0
- package/filters/remove_tag.test.js +60 -0
- package/filters/section.js +82 -0
- package/filters/section.test.js +174 -0
- package/filters/split.js +9 -0
- package/filters/split.test.js +39 -0
- package/filters/strip_tag.js +39 -0
- package/filters/strip_tag.test.js +74 -0
- package/filters/unindent.js +11 -0
- package/filters/unindent.test.js +49 -0
- package/package.json +48 -0
- package/plugin.js +53 -0
- package/plugin.test.js +8 -0
- package/scripts/README.md +59 -0
- package/scripts/package.json +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anyblades/buildawesome-kit-plugin",
|
|
3
|
+
"version": "1.3.0-alpha",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./plugin.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./plugin.js",
|
|
8
|
+
"./features/*": "./features/*"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@11ty/eleventy": "^3.0.0 || ^4.0.0-0",
|
|
12
|
+
"@awesome.me/buildawesome": "^3.0.0 || ^4.0.0-0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependenciesMeta": {
|
|
15
|
+
"@11ty/eleventy": {
|
|
16
|
+
"optional": true
|
|
17
|
+
},
|
|
18
|
+
"@awesome.me/buildawesome": {
|
|
19
|
+
"optional": true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"=== DEV ONLY": "===",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node --test ./**/*.test.js",
|
|
25
|
+
"prepublishOnly": "npm run test"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@11ty/lodash-custom": "^4.17.21"
|
|
29
|
+
},
|
|
30
|
+
"=== METADATA": "===",
|
|
31
|
+
"author": "Anton Staroverov",
|
|
32
|
+
"description": "Essential 11ty filters, pre/post-processors, and other toggleable features as a simple, configurable plugin",
|
|
33
|
+
"homepage": "https://build.blades.ninja/plugin/",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"11ty",
|
|
36
|
+
"buildawesome",
|
|
37
|
+
"eleventy",
|
|
38
|
+
"filters",
|
|
39
|
+
"plugin"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/anyblades/buildawesome-kit.git",
|
|
45
|
+
"directory": "plugin/"
|
|
46
|
+
},
|
|
47
|
+
"===": "==="
|
|
48
|
+
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//<!--section:code-->```js
|
|
2
|
+
import { readdirSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
export const discoverModules = (dir) =>
|
|
5
|
+
Object.fromEntries(
|
|
6
|
+
readdirSync(new URL(dir, import.meta.url))
|
|
7
|
+
.filter((f) => f.endsWith(".js") && !f.endsWith(".test.js"))
|
|
8
|
+
.map((f) => [f.replace(/\.js$/, ""), true]),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default async function (eleventyConfig, userOptions) {
|
|
12
|
+
//```<!--section:code,def-options-->```js
|
|
13
|
+
const defaultOptions = { mdAutoRawTags: false };
|
|
14
|
+
//```<!--section:code-->```js
|
|
15
|
+
const options = Object.assign(
|
|
16
|
+
{},
|
|
17
|
+
discoverModules("./features"),
|
|
18
|
+
{ filters: discoverModules("./filters") },
|
|
19
|
+
defaultOptions,
|
|
20
|
+
userOptions,
|
|
21
|
+
);
|
|
22
|
+
// console.log("[options]", defaultOptions, userOptions, options);
|
|
23
|
+
|
|
24
|
+
/* FILTERS
|
|
25
|
+
* Fallback to default list if options.filters doesn't exist
|
|
26
|
+
* By using import.meta.url, Node figures out exactly where your script is installed inside their node_modules folder and targets the directory relative to that script.
|
|
27
|
+
*/
|
|
28
|
+
const filterNames = Object.entries(options.filters).filter(([, v]) => v);
|
|
29
|
+
for (const [filterName] of filterNames) {
|
|
30
|
+
console.log("Loading filter: " + filterName + "...");
|
|
31
|
+
try {
|
|
32
|
+
if (filterName == "fetch") await import("@11ty/eleventy-fetch");
|
|
33
|
+
const filterFunc = (await import("./filters/" + filterName + ".js")).default;
|
|
34
|
+
eleventyConfig.addFilter(filterName, filterFunc);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.log("^ N/A ^");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* FEATURES */
|
|
41
|
+
delete options.filters;
|
|
42
|
+
const featureNames = Object.entries(options).filter(([, v]) => v);
|
|
43
|
+
for (const [featureName] of featureNames) {
|
|
44
|
+
console.log("Loading feature: " + featureName + "...");
|
|
45
|
+
try {
|
|
46
|
+
const featureConfig = (await import("./features/" + featureName + ".js")).default;
|
|
47
|
+
featureConfig(eleventyConfig);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.log("^ N/A ^");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//```
|
package/plugin.test.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { discoverModules } from "./plugin.js";
|
|
4
|
+
|
|
5
|
+
test("discoverModules - project root returns only 'plugin'", () => {
|
|
6
|
+
const result = discoverModules("./");
|
|
7
|
+
assert.deepStrictEqual(result, { plugin: true });
|
|
8
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
This package provides a pre-configured `do` folder setup that helps organize your development workflow using npm workspaces. The `do` folder contains scripts for building and running your Eleventy project.
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
1. Install https://github.com/anyblades/eleventy-blades to reuse pre-defined 11ty scripts from there:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @anyblades/eleventy-blades
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. Create a helper folder `do` to symlink the `do/package.json` within:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
mkdir do
|
|
15
|
+
cd do/
|
|
16
|
+
ln -s ../node_modules/@anyblades/eleventy-blades/packages/do/package.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. Finally register `do` folder as npm workspace in your root `package.json`:
|
|
20
|
+
|
|
21
|
+
```json {data-caption=./package.json}
|
|
22
|
+
{
|
|
23
|
+
...
|
|
24
|
+
"workspaces": ["do"],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"start": "npm -w do run start",
|
|
27
|
+
"stage": "npm -w do run stage",
|
|
28
|
+
"build": "npm -w do run build"
|
|
29
|
+
},
|
|
30
|
+
...
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Done!** 🎉 Now you can run:
|
|
35
|
+
|
|
36
|
+
- `npm start` to start 11ty dev server with live reload and Tailwind watch mode
|
|
37
|
+
- `npm run stage` to build and serve production-like site locally
|
|
38
|
+
- `npm run build` to finally build the site for production
|
|
39
|
+
- all available scripts: https://github.com/anyblades/eleventy-blades/blob/main/packages/do/package.json
|
|
40
|
+
|
|
41
|
+
## Live examples
|
|
42
|
+
|
|
43
|
+
- https://github.com/anyblades/buildawesome-starters
|
|
44
|
+
- https://github.com/anyblades/subtle/tree/main/.11ty
|
|
45
|
+
- https://github.com/johnheenan/minform
|
|
46
|
+
|
|
47
|
+
## Benefits
|
|
48
|
+
|
|
49
|
+
**Clean separation**
|
|
50
|
+
: Keep build scripts separate from project configuration
|
|
51
|
+
|
|
52
|
+
**Reusable workflows**
|
|
53
|
+
: Update scripts by upgrading the package
|
|
54
|
+
|
|
55
|
+
**Workspace isolation**
|
|
56
|
+
: Scripts run in their own workspace context
|
|
57
|
+
|
|
58
|
+
**Easy maintenance**
|
|
59
|
+
: No need to manually maintain build scripts
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"name": "do",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"=== START": "with-tw: 1) `&` for parallel run 2) `tw` is last to stay alive 3) trap/wait for graceful exit",
|
|
6
|
+
"start": "npm run 11ty -- --serve --incremental",
|
|
7
|
+
"start:with-tw": "trap 'kill 0' INT; npm start & npm run tw -- --watch & wait",
|
|
8
|
+
"=== STAGE": "1) `rm -r` w/o trailing slash to avoid symlink catastrophe! 2) `;` to bypass no dir errors",
|
|
9
|
+
"stage": "rm -r ../_site; npm run build && serve ../_site/",
|
|
10
|
+
"=== BUILD": "`;` to make `tw` optional",
|
|
11
|
+
"build": "npm run tw; npm run 11ty",
|
|
12
|
+
"=== INNER": "commands written so that extra arguments can be passed",
|
|
13
|
+
"11ty": "cd ../ && NODE_OPTIONS='--preserve-symlinks' eleventy ${ELTY_OPTIONS}",
|
|
14
|
+
"tw": "[ -z \"$TW_OPTIONS\" ] && exit 0; cd ../ && tailwindcss ${TW_OPTIONS}",
|
|
15
|
+
"dev:blades": "cd ../ && npm link @anyblades/eleventy-blades-base && cd ./node_modules/@anyblades/ && ln -sf ./eleventy-blades-base/node_modules/@anyblades/*blades* ./ && cd eleventy-blades-base && npm link @anyblades/blades @anyblades/eleventy-blades"
|
|
16
|
+
}
|
|
17
|
+
}
|