├── .gitignore
├── www
├── notes
│ ├── note2
│ │ └── index.html
│ ├── note3
│ │ └── index.html
│ ├── bad
│ │ └── index.html
│ └── note1
│ │ └── index.html
└── tags
│ ├── null
│ └── index.html
│ ├── linux
│ └── index.html
│ ├── hacking
│ └── index.html
│ ├── notes
│ └── index.html
│ └── all
│ └── index.html
├── src
├── notes
│ ├── note2.md
│ ├── note3.md
│ ├── bad.md
│ └── note1.md
└── tags.njk
├── schemas
├── index.js
└── notes.js
├── package.json
└── .eleventy.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/www/notes/note2/index.html:
--------------------------------------------------------------------------------
1 |
hey
2 |
--------------------------------------------------------------------------------
/www/notes/note3/index.html:
--------------------------------------------------------------------------------
1 | Bad schema
2 |
--------------------------------------------------------------------------------
/src/notes/note2.md:
--------------------------------------------------------------------------------
1 | ---
2 | schema: notes
3 | ---
4 | hey
--------------------------------------------------------------------------------
/www/tags/null/index.html:
--------------------------------------------------------------------------------
1 | Étiquette: « null »
2 |
3 |
--------------------------------------------------------------------------------
/www/notes/bad/index.html:
--------------------------------------------------------------------------------
1 | title=📸 Scanner Epson Perfection V39 tags=[null]
2 |
--------------------------------------------------------------------------------
/src/notes/note3.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bad schema
3 | schema: tangerine
4 | ---
5 |
6 | {{ title }}
--------------------------------------------------------------------------------
/www/tags/linux/index.html:
--------------------------------------------------------------------------------
1 | Étiquette: « linux »
2 |
3 |
4 | Test
5 | | 2020-04-17
6 |
7 |
8 |
--------------------------------------------------------------------------------
/www/tags/hacking/index.html:
--------------------------------------------------------------------------------
1 | Étiquette: « hacking »
2 |
3 |
4 | Test
5 | | 2020-04-17
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/notes/bad.md:
--------------------------------------------------------------------------------
1 | ---
2 | # src/notes/bad.md
3 | title: "📸 Scanner Epson Perfection V39"
4 | description:
5 | date: 2022-07-21 20:18:38
6 | cover:
7 | categories:
8 | tags:
9 | -
10 | schema: notes
11 | ---
12 |
13 | title={{ title }}
14 | tags={{ tags | json }}
15 |
--------------------------------------------------------------------------------
/schemas/index.js:
--------------------------------------------------------------------------------
1 | const Ajv = require("ajv");
2 | const addFormats = require("ajv-formats");
3 |
4 | const ajv = new Ajv({ allErrors: true });
5 | addFormats(ajv);
6 |
7 | module.exports = {
8 | ajv,
9 | errorsText(errors = []) {
10 | return ajv.errorsText(errors, {
11 | separator: "\n",
12 | dataVar: "frontmatter",
13 | });
14 | },
15 | notes: ajv.compile(require("./notes")),
16 | };
17 |
--------------------------------------------------------------------------------
/schemas/notes.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | type: "object",
3 | properties: {
4 | title: { type: "string", minLength: 1 },
5 | description: { type: "string", nullable: true },
6 | // date: { type: "string", format: "date-time" },
7 | cover: { type: "string", nullable: true },
8 | categories: { type: "array", items: { type: "string"}, nullable: true },
9 | tags: { type: "array", items: { type: "string", minLength: 1, nullable: false }},
10 | },
11 | required: ["title"],
12 | additionalProperties: true,
13 | };
14 |
--------------------------------------------------------------------------------
/www/tags/notes/index.html:
--------------------------------------------------------------------------------
1 | Étiquette: « notes »
2 |
23 |
--------------------------------------------------------------------------------
/src/tags.njk:
--------------------------------------------------------------------------------
1 | ---
2 | # layout: default
3 | title: "Tag"
4 | description: "Page listing all notes for one tag"
5 | pagination:
6 | data: collections
7 | size: 1
8 | alias: tag
9 | filter:
10 | - $schema
11 | permalink: /tags/{{ tag }}/
12 | ---
13 | Étiquette: « {{ tag }} »
14 |
15 | {% set taglist = collections[ tag ] %}
16 | {% for p in taglist | sort(false, false, 'data.title') %}
17 | {# {% for p in taglist | sortByTitle %} #}
18 | {{ p.data.title }} {%if p.date %}| {{ p.date.toLocaleDateString() }} {% endif %}
19 | {% endfor %}
20 |
21 |
--------------------------------------------------------------------------------
/www/notes/note1/index.html:
--------------------------------------------------------------------------------
1 |
2 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
3 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
4 | voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
5 | kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis
6 | autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
7 | consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et
8 | accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
9 | augue duis dolore te feugait nulla facilisi.
10 |
11 |
--------------------------------------------------------------------------------
/src/notes/note1.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Test"
3 | id: 20210414054101
4 | date: 2020-04-17 20:20:02
5 | tags:
6 | - linux
7 | - hacking
8 | ---
9 |
10 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
11 |
--------------------------------------------------------------------------------
/www/tags/all/index.html:
--------------------------------------------------------------------------------
1 | Étiquette: « all »
2 |
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "11ty-2557",
3 | "description": "",
4 | "version": "1.0.0",
5 | "author": "Peter deHaan ",
6 | "bugs": {
7 | "url": "https://github.com/pdehaan/11ty-2557/issues"
8 | },
9 | "devDependencies": {
10 | "@11ty/eleventy": "^1.0.2",
11 | "ajv": "^8.11.0",
12 | "ajv-formats": "^2.1.1",
13 | "dedent": "^0.7.0"
14 | },
15 | "homepage": "https://github.com/pdehaan/11ty-2557#readme",
16 | "keywords": [],
17 | "license": "MPL-2.0",
18 | "main": ".eleventy.js",
19 | "repository": {
20 | "type": "git",
21 | "url": "git+https://github.com/pdehaan/11ty-2557.git"
22 | },
23 | "scripts": {
24 | "prebuild": "rm -rf www",
25 | "build": "eleventy",
26 | "postbuild": "npx prettier www --write",
27 | "test": "echo \"Error: no test specified\" && exit 1"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.eleventy.js:
--------------------------------------------------------------------------------
1 | // const dedent = require("dedent");
2 | const schemas = require("./schemas");
3 |
4 | /**
5 | * @typedef {import('@11ty/eleventy/src/UserConfig')} EleventyConfig
6 | * @typedef {ReturnType} EleventyReturnValue
7 | * @type {(eleventyConfig: EleventyConfig) => EleventyReturnValue}
8 | */
9 | module.exports = function (eleventyConfig) {
10 | eleventyConfig.addCollection("notes", collectionApi => collectionApi.getFilteredByGlob(["./src/notes/*.md"]));
11 | eleventyConfig.addCollection("$schema", async function (collectionApi) {
12 | const coll = collectionApi.getAll();
13 | const errors = [];
14 | for (const page of coll) {
15 | const {schema, page: {inputPath}} = page.data;
16 | try {
17 | switch (schema) {
18 | case "notes":
19 | const valid = schemas.notes(page.data);
20 | if (!valid) {
21 | errors.push({
22 | inputPath,
23 | message: schemas.errorsText(schemas.notes.errors),
24 | errors: schemas.notes.errors
25 | });
26 | }
27 | break;
28 | default:
29 | if (!!schema && !(schema in schemas)) {
30 | errors.push({
31 | inputPath,
32 | message: `Unknown schema: '${schema}'`
33 | });
34 | }
35 | break;
36 | }
37 | } catch (err) {
38 | console.error(err);
39 | process.exitCode = 2;
40 | }
41 | }
42 | if (errors.length) {
43 | // console.error(JSON.stringify(errors, null, 2));
44 | for (const err of errors) {
45 | console.error(`[${err.inputPath}] ${err.message}`);
46 | }
47 | console.error("");
48 | process.exitCode = 1;
49 | }
50 | return [];
51 | });
52 |
53 | eleventyConfig.setQuietMode(true);
54 |
55 | return {
56 | dir: {
57 | input: "src",
58 | output: "www",
59 | }
60 | };
61 | };
62 |
--------------------------------------------------------------------------------