@t8/docsgen 0.3.10 → 0.3.12
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/dist/bin.js +112 -89
- package/dist/css/base.css +1 -1
- package/package.json +4 -4
- package/schema.json +1 -1
- package/src/bin/parsing/getParsedContent.ts +8 -12
- package/src/css/base.css +1 -1
- package/src/types/EntryConfig.ts +5 -0
- package/.biomeincludes +0 -2
package/dist/bin.js
CHANGED
|
@@ -1,91 +1,118 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// node_modules/args-json/dist/index.cjs
|
|
29
|
+
var require_dist = __commonJS({
|
|
30
|
+
"node_modules/args-json/dist/index.cjs"(exports) {
|
|
31
|
+
function toCamelCase(x) {
|
|
32
|
+
let s = x.replace(/^[-_.\s~+]|[-_.\s~+]$/g, "");
|
|
33
|
+
if (!/[-_.\s~+]/.test(s)) return s.slice(0, 1).toLowerCase() + s.slice(1);
|
|
34
|
+
return s.toLowerCase().replace(/[-_.\s~+](\S)/g, (_, match) => match.toUpperCase());
|
|
35
|
+
}
|
|
36
|
+
function toKey(x) {
|
|
37
|
+
if (x) {
|
|
38
|
+
if (x.startsWith("--") && x.length > 2) return toCamelCase(x.slice(2));
|
|
39
|
+
if (x.startsWith("-") && x.length === 2) return toCamelCase(x.slice(1));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function split(x) {
|
|
43
|
+
let words = [], word = "";
|
|
44
|
+
let hasOpenSingleQuote = false;
|
|
45
|
+
let hasOpenDoubleQuote = false;
|
|
46
|
+
for (let i = 0; i < x.length; i++) {
|
|
47
|
+
let c = x[i];
|
|
48
|
+
if (/^\s/.test(c) && !hasOpenSingleQuote && !hasOpenDoubleQuote) {
|
|
49
|
+
if (word) words.push(word);
|
|
50
|
+
word = "";
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (c === "'" && x[i - 1] !== "\\") hasOpenSingleQuote = !hasOpenSingleQuote;
|
|
54
|
+
if (c === '"' && x[i - 1] !== "\\") hasOpenDoubleQuote = !hasOpenDoubleQuote;
|
|
55
|
+
word += c;
|
|
56
|
+
}
|
|
22
57
|
if (word) words.push(word);
|
|
23
|
-
|
|
24
|
-
continue;
|
|
58
|
+
return words;
|
|
25
59
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (c === '"' && x[i - 1] !== "\\")
|
|
29
|
-
hasOpenDoubleQuote = !hasOpenDoubleQuote;
|
|
30
|
-
word += c;
|
|
31
|
-
}
|
|
32
|
-
if (word) words.push(word);
|
|
33
|
-
return words;
|
|
34
|
-
}
|
|
35
|
-
function getDefaultInput() {
|
|
36
|
-
return typeof process === "undefined" ? [] : process.argv;
|
|
37
|
-
}
|
|
38
|
-
function parseArgs(input, map) {
|
|
39
|
-
let normalizedInput;
|
|
40
|
-
let normalizedMap;
|
|
41
|
-
if (input === void 0) normalizedInput = getDefaultInput();
|
|
42
|
-
else if (typeof input === "string") normalizedInput = split(input);
|
|
43
|
-
else if (Array.isArray(input)) normalizedInput = input.map((x) => String(x));
|
|
44
|
-
else if (input !== null && typeof input === "object") {
|
|
45
|
-
normalizedInput = getDefaultInput();
|
|
46
|
-
normalizedMap = input;
|
|
47
|
-
} else normalizedInput = [];
|
|
48
|
-
normalizedInput = normalizedInput.flatMap((item) => {
|
|
49
|
-
let normalizedItem = item.trim();
|
|
50
|
-
let k = normalizedItem.indexOf("=");
|
|
51
|
-
if (k === -1) return normalizedItem;
|
|
52
|
-
return [normalizedItem.slice(0, k), normalizedItem.slice(k + 1)];
|
|
53
|
-
});
|
|
54
|
-
if (map) normalizedMap = map;
|
|
55
|
-
let key = "";
|
|
56
|
-
let parsedArgs = {};
|
|
57
|
-
for (let rawValue of normalizedInput) {
|
|
58
|
-
rawValue = rawValue.trim();
|
|
59
|
-
if (rawValue.startsWith('"') && rawValue.endsWith('"'))
|
|
60
|
-
rawValue = rawValue.slice(1, -1);
|
|
61
|
-
else if (rawValue.startsWith("'") && rawValue.endsWith("'"))
|
|
62
|
-
rawValue = rawValue.slice(1, -1);
|
|
63
|
-
let parsedKey = toKey(rawValue);
|
|
64
|
-
if (parsedKey !== void 0) {
|
|
65
|
-
let nextKey = normalizedMap?.[parsedKey] ?? parsedKey;
|
|
66
|
-
if (key && nextKey !== key && parsedArgs[key] === void 0)
|
|
67
|
-
parsedArgs[key] = true;
|
|
68
|
-
key = nextKey;
|
|
69
|
-
continue;
|
|
60
|
+
function getDefaultInput() {
|
|
61
|
+
return typeof process === "undefined" ? [] : process.argv;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
function parseArgs2(input, map) {
|
|
64
|
+
let normalizedInput;
|
|
65
|
+
let normalizedMap;
|
|
66
|
+
if (input === void 0) normalizedInput = getDefaultInput();
|
|
67
|
+
else if (typeof input === "string") normalizedInput = split(input);
|
|
68
|
+
else if (Array.isArray(input)) normalizedInput = input.map((x) => String(x));
|
|
69
|
+
else if (input !== null && typeof input === "object") {
|
|
70
|
+
normalizedInput = getDefaultInput();
|
|
71
|
+
normalizedMap = input;
|
|
72
|
+
} else normalizedInput = [];
|
|
73
|
+
normalizedInput = normalizedInput.flatMap((item) => {
|
|
74
|
+
let normalizedItem = item.trim();
|
|
75
|
+
let k = normalizedItem.indexOf("=");
|
|
76
|
+
if (k === -1) return normalizedItem;
|
|
77
|
+
return [normalizedItem.slice(0, k), normalizedItem.slice(k + 1)];
|
|
78
|
+
});
|
|
79
|
+
if (map) normalizedMap = map;
|
|
80
|
+
let key = "";
|
|
81
|
+
let parsedArgs = {};
|
|
82
|
+
for (let rawValue of normalizedInput) {
|
|
83
|
+
rawValue = rawValue.trim();
|
|
84
|
+
if (rawValue.startsWith('"') && rawValue.endsWith('"')) rawValue = rawValue.slice(1, -1);
|
|
85
|
+
else if (rawValue.startsWith("'") && rawValue.endsWith("'")) rawValue = rawValue.slice(1, -1);
|
|
86
|
+
let parsedKey = toKey(rawValue);
|
|
87
|
+
if (parsedKey !== void 0) {
|
|
88
|
+
let nextKey = normalizedMap?.[parsedKey] ?? parsedKey;
|
|
89
|
+
if (key && nextKey !== key && parsedArgs[key] === void 0) parsedArgs[key] = true;
|
|
90
|
+
key = nextKey;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let parsedValue;
|
|
94
|
+
if (rawValue) try {
|
|
95
|
+
parsedValue = JSON.parse(rawValue);
|
|
96
|
+
} catch {
|
|
97
|
+
parsedValue = rawValue;
|
|
98
|
+
}
|
|
99
|
+
else parsedValue = true;
|
|
100
|
+
let prevValue = parsedArgs[key];
|
|
101
|
+
let value;
|
|
102
|
+
if (prevValue === void 0) value = parsedValue;
|
|
103
|
+
else if (Array.isArray(prevValue)) value = [...prevValue, parsedValue];
|
|
104
|
+
else value = [prevValue, parsedValue];
|
|
105
|
+
parsedArgs[key] = value;
|
|
77
106
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
else if (Array.isArray(prevValue)) value = [...prevValue, parsedValue];
|
|
83
|
-
else value = [prevValue, parsedValue];
|
|
84
|
-
parsedArgs[key] = value;
|
|
107
|
+
if (key && parsedArgs[key] === void 0) parsedArgs[key] = true;
|
|
108
|
+
return parsedArgs;
|
|
109
|
+
}
|
|
110
|
+
exports.parseArgs = parseArgs2;
|
|
85
111
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// src/bin/getConfig.ts
|
|
115
|
+
var import_args_json = __toESM(require_dist(), 1);
|
|
89
116
|
|
|
90
117
|
// src/bin/fetchContent.ts
|
|
91
118
|
import { readFile } from "node:fs/promises";
|
|
@@ -205,7 +232,7 @@ async function getConfig() {
|
|
|
205
232
|
root: "/",
|
|
206
233
|
contentDir: "x",
|
|
207
234
|
...localConfig,
|
|
208
|
-
...parseArgs(args)
|
|
235
|
+
...(0, import_args_json.parseArgs)(args)
|
|
209
236
|
};
|
|
210
237
|
if (config.entries) {
|
|
211
238
|
config.targetIds = targetArgs;
|
|
@@ -542,7 +569,7 @@ var md = new Markdown({
|
|
|
542
569
|
html: true
|
|
543
570
|
});
|
|
544
571
|
async function getParsedContent(ctx) {
|
|
545
|
-
let { singlePage, linkMap } = ctx;
|
|
572
|
+
let { singlePage, firstLineDescription, linkMap } = ctx;
|
|
546
573
|
let rawContent = await fetchContent(
|
|
547
574
|
getLocation(ctx, "README.md", ctx.source)
|
|
548
575
|
);
|
|
@@ -566,7 +593,7 @@ async function getParsedContent(ctx) {
|
|
|
566
593
|
continue;
|
|
567
594
|
}
|
|
568
595
|
if (element.matches("h1")) {
|
|
569
|
-
title = element.innerHTML;
|
|
596
|
+
title = element.innerHTML.trim();
|
|
570
597
|
continue;
|
|
571
598
|
}
|
|
572
599
|
if (element.matches("h2")) {
|
|
@@ -597,7 +624,7 @@ async function getParsedContent(ctx) {
|
|
|
597
624
|
installation = installationCode;
|
|
598
625
|
continue;
|
|
599
626
|
}
|
|
600
|
-
if (element.matches("p") && description.length === 0) {
|
|
627
|
+
if (title && firstLineDescription && element.matches("p") && description.length === 0) {
|
|
601
628
|
description.push(outerHTML);
|
|
602
629
|
continue;
|
|
603
630
|
}
|
|
@@ -608,10 +635,6 @@ async function getParsedContent(ctx) {
|
|
|
608
635
|
...navLinkMap,
|
|
609
636
|
...linkMap
|
|
610
637
|
});
|
|
611
|
-
if (intro.length !== 0 && description.length !== 0 && !description[0].startsWith("<p><em>")) {
|
|
612
|
-
intro.unshift(description[0]);
|
|
613
|
-
description = [];
|
|
614
|
-
}
|
|
615
638
|
if (intro.at(-1) === "<hr>") intro.pop();
|
|
616
639
|
for (let i = 0; i < intro.length; i++) {
|
|
617
640
|
if (intro[i].includes("<br>") && intro[i].startsWith("<p>") && intro[i].endsWith("</p>")) {
|
package/dist/css/base.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/bin.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/jsdom": "^27.0.0",
|
|
28
28
|
"@types/markdown-it": "^14.1.2",
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^25.0.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"args-json": "^1.2.
|
|
33
|
-
"jsdom": "^27.
|
|
32
|
+
"args-json": "^1.2.9",
|
|
33
|
+
"jsdom": "^27.3.0",
|
|
34
34
|
"markdown-it": "^14.1.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/schema.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetIds":{"items":{"type":"string"},"type":"array"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap":{"additionalProperties":false,"properties":{":has-code":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"cover":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
|
|
1
|
+
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetIds":{"items":{"type":"string"},"type":"array"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap":{"additionalProperties":false,"properties":{":has-code":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"cover":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
|
|
@@ -15,7 +15,7 @@ const md = new Markdown({
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
export async function getParsedContent(ctx: Context) {
|
|
18
|
-
let { singlePage, linkMap } = ctx;
|
|
18
|
+
let { singlePage, firstLineDescription, linkMap } = ctx;
|
|
19
19
|
let rawContent = await fetchContent(
|
|
20
20
|
getLocation(ctx, "README.md", ctx.source),
|
|
21
21
|
);
|
|
@@ -45,7 +45,7 @@ export async function getParsedContent(ctx: Context) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (element.matches("h1")) {
|
|
48
|
-
title = element.innerHTML;
|
|
48
|
+
title = element.innerHTML.trim();
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -87,7 +87,12 @@ export async function getParsedContent(ctx: Context) {
|
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
if (
|
|
90
|
+
if (
|
|
91
|
+
title &&
|
|
92
|
+
firstLineDescription &&
|
|
93
|
+
element.matches("p") &&
|
|
94
|
+
description.length === 0
|
|
95
|
+
) {
|
|
91
96
|
description.push(outerHTML);
|
|
92
97
|
continue;
|
|
93
98
|
}
|
|
@@ -102,15 +107,6 @@ export async function getParsedContent(ctx: Context) {
|
|
|
102
107
|
...linkMap,
|
|
103
108
|
});
|
|
104
109
|
|
|
105
|
-
if (
|
|
106
|
-
intro.length !== 0 &&
|
|
107
|
-
description.length !== 0 &&
|
|
108
|
-
!description[0].startsWith("<p><em>")
|
|
109
|
-
) {
|
|
110
|
-
intro.unshift(description[0]);
|
|
111
|
-
description = [];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
110
|
if (intro.at(-1) === "<hr>") intro.pop();
|
|
115
111
|
|
|
116
112
|
for (let i = 0; i < intro.length; i++) {
|
package/src/css/base.css
CHANGED
package/src/types/EntryConfig.ts
CHANGED
|
@@ -13,6 +13,11 @@ export type EntryConfig = {
|
|
|
13
13
|
title?: string;
|
|
14
14
|
htmlTitle?: string;
|
|
15
15
|
description?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the first line following the main title is the package
|
|
18
|
+
* description.
|
|
19
|
+
*/
|
|
20
|
+
firstLineDescription?: boolean;
|
|
16
21
|
version?: string;
|
|
17
22
|
repo?: string;
|
|
18
23
|
npm?: string;
|
package/.biomeincludes
DELETED