@docusaurus/utils 0.0.0-4757 → 0.0.0-4761
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/lib/constants.d.ts +49 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +53 -8
- package/lib/constants.js.map +1 -1
- package/lib/dataFileUtils.d.ts +38 -2
- package/lib/dataFileUtils.d.ts.map +1 -1
- package/lib/dataFileUtils.js +34 -7
- package/lib/dataFileUtils.js.map +1 -1
- package/lib/emitUtils.d.ts +12 -0
- package/lib/emitUtils.d.ts.map +1 -1
- package/lib/emitUtils.js +22 -3
- package/lib/emitUtils.js.map +1 -1
- package/lib/gitUtils.d.ts +42 -2
- package/lib/gitUtils.d.ts.map +1 -1
- package/lib/gitUtils.js +2 -2
- package/lib/gitUtils.js.map +1 -1
- package/lib/globUtils.d.ts +27 -0
- package/lib/globUtils.d.ts.map +1 -1
- package/lib/globUtils.js +28 -10
- package/lib/globUtils.js.map +1 -1
- package/lib/hashUtils.d.ts +5 -4
- package/lib/hashUtils.d.ts.map +1 -1
- package/lib/hashUtils.js +6 -5
- package/lib/hashUtils.js.map +1 -1
- package/lib/i18nUtils.d.ts +11 -0
- package/lib/i18nUtils.d.ts.map +1 -1
- package/lib/i18nUtils.js +12 -3
- package/lib/i18nUtils.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/jsUtils.d.ts +32 -4
- package/lib/jsUtils.d.ts.map +1 -1
- package/lib/jsUtils.js +35 -13
- package/lib/jsUtils.js.map +1 -1
- package/lib/markdownLinks.d.ts +45 -4
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +17 -8
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownUtils.d.ts +80 -9
- package/lib/markdownUtils.d.ts.map +1 -1
- package/lib/markdownUtils.js +61 -10
- package/lib/markdownUtils.js.map +1 -1
- package/lib/pathUtils.d.ts +1 -1
- package/lib/pathUtils.d.ts.map +1 -1
- package/lib/pathUtils.js +2 -2
- package/lib/pathUtils.js.map +1 -1
- package/lib/slugger.d.ts +10 -0
- package/lib/slugger.d.ts.map +1 -1
- package/lib/slugger.js +4 -0
- package/lib/slugger.js.map +1 -1
- package/lib/tags.d.ts +31 -10
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +38 -24
- package/lib/tags.js.map +1 -1
- package/lib/urlUtils.d.ts +45 -2
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +48 -6
- package/lib/urlUtils.js.map +1 -1
- package/lib/webpackUtils.d.ts +5 -0
- package/lib/webpackUtils.d.ts.map +1 -1
- package/lib/webpackUtils.js +6 -2
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/constants.ts +59 -7
- package/src/dataFileUtils.ts +43 -10
- package/src/emitUtils.ts +24 -5
- package/src/gitUtils.ts +46 -4
- package/src/globUtils.ts +29 -13
- package/src/hashUtils.ts +6 -5
- package/src/i18nUtils.ts +13 -4
- package/src/index.ts +3 -6
- package/src/jsUtils.ts +34 -20
- package/src/markdownLinks.ts +58 -22
- package/src/markdownUtils.ts +101 -23
- package/src/pathUtils.ts +2 -2
- package/src/slugger.ts +13 -1
- package/src/tags.ts +37 -25
- package/src/urlUtils.ts +49 -6
- package/src/webpackUtils.ts +10 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownUtils.d.ts","sourceRoot":"","sources":["../src/markdownUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"markdownUtils.d.ts","sourceRoot":"","sources":["../src/markdownUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA8B,KAAK,cAAc,EAAC,MAAM,WAAW,CAAC;AAM3E;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG;IAC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AAM,EACf,OAAO,GAAE,qBAA+D,GACvE,MAAM,CAoCR"}
|
package/lib/markdownUtils.js
CHANGED
|
@@ -11,8 +11,16 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
12
|
const gray_matter_1 = tslib_1.__importDefault(require("gray-matter"));
|
|
13
13
|
const slugger_1 = require("./slugger");
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// Some utilities for parsing Markdown content. These things are only used on
|
|
15
|
+
// server-side when we infer metadata like `title` and `description` from the
|
|
16
|
+
// content. Most parsing is still done in MDX through the mdx-loader.
|
|
17
|
+
/**
|
|
18
|
+
* Parses custom ID from a heading. The ID must be composed of letters,
|
|
19
|
+
* underscores, and dashes only.
|
|
20
|
+
*
|
|
21
|
+
* @param heading e.g. `## Some heading {#some-heading}` where the last
|
|
22
|
+
* character must be `}` for the ID to be recognized
|
|
23
|
+
*/
|
|
16
24
|
function parseMarkdownHeadingId(heading) {
|
|
17
25
|
const customHeadingIdRegex = /\s*\{#(?<id>[\w-]+)\}$/;
|
|
18
26
|
const matches = customHeadingIdRegex.exec(heading);
|
|
@@ -25,24 +33,38 @@ function parseMarkdownHeadingId(heading) {
|
|
|
25
33
|
return { text: heading, id: undefined };
|
|
26
34
|
}
|
|
27
35
|
exports.parseMarkdownHeadingId = parseMarkdownHeadingId;
|
|
28
|
-
// Hacky way of stripping out import statements from the excerpt
|
|
29
36
|
// TODO: Find a better way to do so, possibly by compiling the Markdown content,
|
|
30
37
|
// stripping out HTML tags and obtaining the first line.
|
|
38
|
+
/**
|
|
39
|
+
* Creates an excerpt of a Markdown file. This function will:
|
|
40
|
+
*
|
|
41
|
+
* - Ignore h1 headings (setext or atx)
|
|
42
|
+
* - Ignore import/export
|
|
43
|
+
* - Ignore code blocks
|
|
44
|
+
*
|
|
45
|
+
* And for the first contentful line, it will strip away most Markdown
|
|
46
|
+
* syntax, including HTML tags, emphasis, links (keeping the text), etc.
|
|
47
|
+
*/
|
|
31
48
|
function createExcerpt(fileString) {
|
|
32
49
|
const fileLines = fileString
|
|
33
|
-
.
|
|
50
|
+
.trimStart()
|
|
34
51
|
// Remove Markdown alternate title
|
|
35
52
|
.replace(/^[^\n]*\n[=]+/g, '')
|
|
36
53
|
.split('\n');
|
|
37
54
|
let inCode = false;
|
|
55
|
+
let inImport = false;
|
|
38
56
|
let lastCodeFence = '';
|
|
39
57
|
for (const fileLine of fileLines) {
|
|
58
|
+
if (fileLine === '' && inImport) {
|
|
59
|
+
inImport = false;
|
|
60
|
+
}
|
|
40
61
|
// Skip empty line.
|
|
41
62
|
if (!fileLine.trim()) {
|
|
42
63
|
continue;
|
|
43
64
|
}
|
|
44
65
|
// Skip import/export declaration.
|
|
45
|
-
if (/^(?:import|export)\s.*/.test(fileLine)) {
|
|
66
|
+
if ((/^(?:import|export)\s.*/.test(fileLine) || inImport) && !inCode) {
|
|
67
|
+
inImport = true;
|
|
46
68
|
continue;
|
|
47
69
|
}
|
|
48
70
|
// Skip code block line.
|
|
@@ -97,6 +119,18 @@ function createExcerpt(fileString) {
|
|
|
97
119
|
return undefined;
|
|
98
120
|
}
|
|
99
121
|
exports.createExcerpt = createExcerpt;
|
|
122
|
+
/**
|
|
123
|
+
* Takes a raw Markdown file content, and parses the front matter using
|
|
124
|
+
* gray-matter. Worth noting that gray-matter accepts TOML and other markup
|
|
125
|
+
* languages as well.
|
|
126
|
+
*
|
|
127
|
+
* @throws Throws when gray-matter throws. e.g.:
|
|
128
|
+
* ```md
|
|
129
|
+
* ---
|
|
130
|
+
* foo: : bar
|
|
131
|
+
* ---
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
100
134
|
function parseFrontMatter(markdownFileContent) {
|
|
101
135
|
const { data, content } = (0, gray_matter_1.default)(markdownFileContent);
|
|
102
136
|
return {
|
|
@@ -105,17 +139,23 @@ function parseFrontMatter(markdownFileContent) {
|
|
|
105
139
|
};
|
|
106
140
|
}
|
|
107
141
|
exports.parseFrontMatter = parseFrontMatter;
|
|
108
|
-
/**
|
|
109
|
-
* Try to convert markdown heading to text. Does not need to be perfect, it is
|
|
110
|
-
* only used as a fallback when frontMatter.title is not provided. For now, we
|
|
111
|
-
* just unwrap possible inline code blocks (# `config.js`)
|
|
112
|
-
*/
|
|
113
142
|
function toTextContentTitle(contentTitle) {
|
|
114
143
|
if (contentTitle.startsWith('`') && contentTitle.endsWith('`')) {
|
|
115
144
|
return contentTitle.substring(1, contentTitle.length - 1);
|
|
116
145
|
}
|
|
117
146
|
return contentTitle;
|
|
118
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Takes the raw Markdown content, without front matter, and tries to find an h1
|
|
150
|
+
* title (setext or atx) to be used as metadata.
|
|
151
|
+
*
|
|
152
|
+
* It only searches until the first contentful paragraph, ignoring import/export
|
|
153
|
+
* declarations.
|
|
154
|
+
*
|
|
155
|
+
* It will try to convert markdown to reasonable text, but won't be best effort,
|
|
156
|
+
* since it's only used as a fallback when `frontMatter.title` is not provided.
|
|
157
|
+
* For now, we just unwrap inline code (``# `config.js` `` => `config.js`).
|
|
158
|
+
*/
|
|
119
159
|
function parseMarkdownContentTitle(contentUntrimmed, options) {
|
|
120
160
|
const removeContentTitleOption = options?.removeContentTitle ?? false;
|
|
121
161
|
const content = contentUntrimmed.trim();
|
|
@@ -148,6 +188,12 @@ function parseMarkdownContentTitle(contentUntrimmed, options) {
|
|
|
148
188
|
};
|
|
149
189
|
}
|
|
150
190
|
exports.parseMarkdownContentTitle = parseMarkdownContentTitle;
|
|
191
|
+
/**
|
|
192
|
+
* Makes a full-round parse.
|
|
193
|
+
*
|
|
194
|
+
* @throws Throws when `parseFrontMatter` throws, usually because of invalid
|
|
195
|
+
* syntax.
|
|
196
|
+
*/
|
|
151
197
|
function parseMarkdownString(markdownFileContent, options) {
|
|
152
198
|
try {
|
|
153
199
|
const { frontMatter, content: contentWithoutFrontMatter } = parseFrontMatter(markdownFileContent);
|
|
@@ -182,6 +228,11 @@ function addHeadingId(line, slugger, maintainCase) {
|
|
|
182
228
|
});
|
|
183
229
|
return `${headingHashes}${headingText} {#${slug}}`;
|
|
184
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Takes Markdown content, returns new content with heading IDs written.
|
|
233
|
+
* Respects existing IDs (unless `overwrite=true`) and never generates colliding
|
|
234
|
+
* IDs (through the slugger).
|
|
235
|
+
*/
|
|
185
236
|
function writeMarkdownHeadingId(content, options = { maintainCase: false, overwrite: false }) {
|
|
186
237
|
const { maintainCase = false, overwrite = false } = options;
|
|
187
238
|
const lines = content.split('\n');
|
package/lib/markdownUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownUtils.js","sourceRoot":"","sources":["../src/markdownUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wEAAwC;AACxC,sEAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"markdownUtils.js","sourceRoot":"","sources":["../src/markdownUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wEAAwC;AACxC,sEAAiC;AACjC,uCAA2E;AAE3E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AAErE;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IAQpD,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;IACtD,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,OAAO,EAAE;QACX,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;YACtC,EAAE,EAAE,OAAO,CAAC,MAAO,CAAC,EAAG;SACxB,CAAC;KACH;IACD,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAC,CAAC;AACxC,CAAC;AAjBD,wDAiBC;AAED,gFAAgF;AAChF,wDAAwD;AACxD;;;;;;;;;GASG;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AAE;YAClC,OAAO,IAAI,CAAC;SACb;QACD,OAAO,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAvCD,wDAuCC"}
|
package/lib/pathUtils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export declare const isNameTooLong: (str: string) => boolean;
|
|
8
|
-
export declare
|
|
8
|
+
export declare function shortName(str: string): string;
|
|
9
9
|
/**
|
|
10
10
|
* Convert Windows backslash paths to posix style paths.
|
|
11
11
|
* E.g: endi\lie -> endi/lie
|
package/lib/pathUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAIgC,CAAC;AAE7E,
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAIgC,CAAC;AAE7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAY7C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5D"}
|
package/lib/pathUtils.js
CHANGED
|
@@ -24,7 +24,7 @@ isMacOs() || isWindows()
|
|
|
24
24
|
? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
|
|
25
25
|
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
|
26
26
|
exports.isNameTooLong = isNameTooLong;
|
|
27
|
-
|
|
27
|
+
function shortName(str) {
|
|
28
28
|
if (isMacOs() || isWindows()) {
|
|
29
29
|
const overflowingChars = str.length - MAX_PATH_SEGMENT_CHARS;
|
|
30
30
|
return str.slice(0, str.length - overflowingChars - SPACE_FOR_APPENDING - 1);
|
|
@@ -34,7 +34,7 @@ const shortName = (str) => {
|
|
|
34
34
|
return strBuffer
|
|
35
35
|
.slice(0, Buffer.byteLength(strBuffer) - overflowingBytes - SPACE_FOR_APPENDING - 1)
|
|
36
36
|
.toString();
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
exports.shortName = shortName;
|
|
39
39
|
/**
|
|
40
40
|
* Convert Windows backslash paths to posix style paths.
|
package/lib/pathUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AAExB,+DAA+D;AAC/D,qEAAqE;AACrE,qBAAqB;AACrB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpD,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C,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjE,0DAA0D;IAC1D,8CAA8C;IAC9C,OAAO,SAAS,YAAY,EAAE,CAAC;AACjC,CAAC;AALD,0CAKC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAEpC,uCAAuC;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AALD,gCAKC;AAED,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,GAAG,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC;QAC3B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,sEAAsE;YACtE,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,cAAI,CAAC,GAAG,EAAE,CAAC;AAC7C,CAAC;AALD,4DAKC"}
|
package/lib/slugger.d.ts
CHANGED
|
@@ -5,10 +5,20 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export declare type SluggerOptions = {
|
|
8
|
+
/** Keep the headings' casing, otherwise make all lowercase. */
|
|
8
9
|
maintainCase?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare type Slugger = {
|
|
12
|
+
/**
|
|
13
|
+
* Takes a Markdown heading like "Josh Cena" and sluggifies it according to
|
|
14
|
+
* GitHub semantics (in this case `josh-cena`). Stateful, because if you try
|
|
15
|
+
* to sluggify "Josh Cena" again it would return `josh-cena-1`.
|
|
16
|
+
*/
|
|
11
17
|
slug: (value: string, options?: SluggerOptions) => string;
|
|
12
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* A thin wrapper around github-slugger. This is a factory function that returns
|
|
21
|
+
* a stateful Slugger object.
|
|
22
|
+
*/
|
|
13
23
|
export declare function createSlugger(): Slugger;
|
|
14
24
|
//# sourceMappingURL=slugger.d.ts.map
|
package/lib/slugger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slugger.d.ts","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,oBAAY,cAAc,GAAG;
|
|
1
|
+
{"version":3,"file":"slugger.d.ts","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,oBAAY,cAAc,GAAG;IAC3B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC"}
|
package/lib/slugger.js
CHANGED
|
@@ -9,6 +9,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createSlugger = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const github_slugger_1 = tslib_1.__importDefault(require("github-slugger"));
|
|
12
|
+
/**
|
|
13
|
+
* A thin wrapper around github-slugger. This is a factory function that returns
|
|
14
|
+
* a stateful Slugger object.
|
|
15
|
+
*/
|
|
12
16
|
function createSlugger() {
|
|
13
17
|
const githubSlugger = new github_slugger_1.default();
|
|
14
18
|
return {
|
package/lib/slugger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slugger.js","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4EAA2C;
|
|
1
|
+
{"version":3,"file":"slugger.js","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4EAA2C;AAmB3C;;;GAGG;AACH,SAAgB,aAAa;IAC3B,MAAM,aAAa,GAAG,IAAI,wBAAa,EAAE,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC;KAC3E,CAAC;AACJ,CAAC;AALD,sCAKC"}
|
package/lib/tags.d.ts
CHANGED
|
@@ -6,22 +6,43 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare type Tag = {
|
|
8
8
|
label: string;
|
|
9
|
+
/** Permalink to this tag's page, without the `/tags/` base path. */
|
|
9
10
|
permalink: string;
|
|
10
11
|
};
|
|
11
12
|
export declare type FrontMatterTag = string | Tag;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Takes tag objects as they are defined in front matter, and normalizes each
|
|
15
|
+
* into a standard tag object. The permalink is created by appending the
|
|
16
|
+
* sluggified label to `tagsPath`. Front matter tags already containing
|
|
17
|
+
* permalinks would still have `tagsPath` prepended.
|
|
18
|
+
*
|
|
19
|
+
* The result will always be unique by permalinks. The behavior with colliding
|
|
20
|
+
* permalinks is undetermined.
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeFrontMatterTags(
|
|
23
|
+
/** Base path to append the tag permalinks to. */
|
|
24
|
+
tagsPath: string,
|
|
25
|
+
/** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
|
|
26
|
+
frontMatterTags?: FrontMatterTag[] | undefined): Tag[];
|
|
27
|
+
declare type TaggedItemGroup<Item> = {
|
|
15
28
|
tag: Tag;
|
|
16
29
|
items: Item[];
|
|
17
30
|
};
|
|
18
31
|
/**
|
|
19
|
-
* Permits to group docs/
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
32
|
+
* Permits to group docs/blog posts by tag (provided by front matter).
|
|
33
|
+
*
|
|
34
|
+
* @returns a map from tag permalink to the items and other relevant tag data.
|
|
35
|
+
* The record is indexed by permalink, because routes must be unique in the end.
|
|
36
|
+
* Labels may vary on 2 MD files but they are normalized. Docs with
|
|
37
|
+
* label='some label' and label='some-label' should end up in the same page.
|
|
25
38
|
*/
|
|
26
|
-
export declare function groupTaggedItems<Item>(items: readonly Item[],
|
|
39
|
+
export declare function groupTaggedItems<Item>(items: readonly Item[],
|
|
40
|
+
/**
|
|
41
|
+
* A callback telling me how to get the tags list of the current item. Usually
|
|
42
|
+
* simply getting it from some metadata of the current item.
|
|
43
|
+
*/
|
|
44
|
+
getItemTags: (item: Item) => readonly Tag[]): {
|
|
45
|
+
[permalink: string]: TaggedItemGroup<Item>;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
27
48
|
//# sourceMappingURL=tags.d.ts.map
|
package/lib/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,oBAAY,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,oBAAY,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;AAgC1C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB;AACtC,iDAAiD;AACjD,QAAQ,EAAE,MAAM;AAChB,8EAA8E;AAC9E,eAAe,GAAE,cAAc,EAAE,GAAG,SAAc,GACjD,GAAG,EAAE,CAMP;AAED,aAAK,eAAe,CAAC,IAAI,IAAI;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EACnC,KAAK,EAAE,SAAS,IAAI,EAAE;AACtB;;;GAGG;AACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,GAAG,EAAE,GAC1C;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CAAC,CA0B9C"}
|
package/lib/tags.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.groupTaggedItems = exports.normalizeFrontMatterTags =
|
|
9
|
+
exports.groupTaggedItems = exports.normalizeFrontMatterTags = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const urlUtils_1 = require("./urlUtils");
|
|
@@ -32,38 +32,52 @@ function normalizeFrontMatterTag(tagsPath, frontMatterTag) {
|
|
|
32
32
|
permalink: normalizeTagPermalink(tag.permalink),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Takes tag objects as they are defined in front matter, and normalizes each
|
|
37
|
+
* into a standard tag object. The permalink is created by appending the
|
|
38
|
+
* sluggified label to `tagsPath`. Front matter tags already containing
|
|
39
|
+
* permalinks would still have `tagsPath` prepended.
|
|
40
|
+
*
|
|
41
|
+
* The result will always be unique by permalinks. The behavior with colliding
|
|
42
|
+
* permalinks is undetermined.
|
|
43
|
+
*/
|
|
44
|
+
function normalizeFrontMatterTags(
|
|
45
|
+
/** Base path to append the tag permalinks to. */
|
|
46
|
+
tagsPath,
|
|
47
|
+
/** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
|
|
48
|
+
frontMatterTags = []) {
|
|
37
49
|
const tags = frontMatterTags.map((tag) => normalizeFrontMatterTag(tagsPath, tag));
|
|
38
50
|
return lodash_1.default.uniqBy(tags, (tag) => tag.permalink);
|
|
39
51
|
}
|
|
40
52
|
exports.normalizeFrontMatterTags = normalizeFrontMatterTags;
|
|
41
53
|
/**
|
|
42
|
-
* Permits to group docs/
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
54
|
+
* Permits to group docs/blog posts by tag (provided by front matter).
|
|
55
|
+
*
|
|
56
|
+
* @returns a map from tag permalink to the items and other relevant tag data.
|
|
57
|
+
* The record is indexed by permalink, because routes must be unique in the end.
|
|
58
|
+
* Labels may vary on 2 MD files but they are normalized. Docs with
|
|
59
|
+
* label='some label' and label='some-label' should end up in the same page.
|
|
60
|
+
*/
|
|
61
|
+
function groupTaggedItems(items,
|
|
62
|
+
/**
|
|
63
|
+
* A callback telling me how to get the tags list of the current item. Usually
|
|
64
|
+
* simply getting it from some metadata of the current item.
|
|
48
65
|
*/
|
|
49
|
-
|
|
66
|
+
getItemTags) {
|
|
50
67
|
const result = {};
|
|
51
|
-
function handleItemTag(item, tag) {
|
|
52
|
-
var _a;
|
|
53
|
-
// Init missing tag groups
|
|
54
|
-
// TODO: it's not really clear what should be the behavior if 2 items have
|
|
55
|
-
// the same tag but the permalink is different for each
|
|
56
|
-
// For now, the first tag found wins
|
|
57
|
-
result[_a = tag.permalink] ?? (result[_a] = {
|
|
58
|
-
tag,
|
|
59
|
-
items: [],
|
|
60
|
-
});
|
|
61
|
-
// Add item to group
|
|
62
|
-
result[tag.permalink].items.push(item);
|
|
63
|
-
}
|
|
64
68
|
items.forEach((item) => {
|
|
65
69
|
getItemTags(item).forEach((tag) => {
|
|
66
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
// Init missing tag groups
|
|
72
|
+
// TODO: it's not really clear what should be the behavior if 2 tags have
|
|
73
|
+
// the same permalink but the label is different for each
|
|
74
|
+
// For now, the first tag found wins
|
|
75
|
+
result[_a = tag.permalink] ?? (result[_a] = {
|
|
76
|
+
tag,
|
|
77
|
+
items: [],
|
|
78
|
+
});
|
|
79
|
+
// Add item to group
|
|
80
|
+
result[tag.permalink].items.push(item);
|
|
67
81
|
});
|
|
68
82
|
});
|
|
69
83
|
// If user add twice the same tag to a md doc (weird but possible),
|
package/lib/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;AAUxC,SAAS,uBAAuB,CAC9B,QAAgB,EAChB,cAA8B;IAE9B,SAAS,WAAW,CAAC,SAAiB;QACpC,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,gBAAC,CAAC,SAAS,CAAC,SAAS,CAAC;SAClC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,SAAS,qBAAqB,CAAC,SAAiB;QAC9C,2EAA2E;QAC3E,2EAA2E;QAC3E,mDAAmD;QACnD,OAAO,IAAA,uBAAY,EAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,GAAG,GACP,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC;QAC7B,CAAC,CAAC,cAAc,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC;KAChD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,wB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4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Much like `path.join`, but much better. Takes an array of URL segments, and
|
|
9
|
+
* joins them into a reasonable URL.
|
|
10
|
+
*
|
|
11
|
+
* - `["file:", "/home", "/user/", "website"]` => `file:///home/user/website`
|
|
12
|
+
* - `["file://", "home", "/user/", "website"]` => `file://home/user/website` (relative!)
|
|
13
|
+
* - Remove trailing slash before parameters or hash.
|
|
14
|
+
* - Replace `?` in query parameters with `&`.
|
|
15
|
+
* - Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
|
16
|
+
*
|
|
17
|
+
* @throws {TypeError} If any of the URL segment is not a string, this throws.
|
|
18
|
+
*/
|
|
7
19
|
export declare function normalizeUrl(rawUrls: string[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Takes a file's path, relative to its content folder, and computes its edit
|
|
22
|
+
* URL. If `editUrl` is `undefined`, this returns `undefined`, as is the case
|
|
23
|
+
* when the user doesn't want an edit URL in her config.
|
|
24
|
+
*/
|
|
8
25
|
export declare function getEditUrl(fileRelativePath: string, editUrl?: string): string | undefined;
|
|
9
26
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
27
|
+
* Converts file path to a reasonable URL path, e.g. `'index.md'` -> `'/'`,
|
|
28
|
+
* `'foo/bar.js'` -> `'/foo/bar'`
|
|
12
29
|
*/
|
|
13
30
|
export declare function fileToPath(file: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Similar to `encodeURI`, but uses `encodeURIComponent` and assumes there's no
|
|
33
|
+
* query.
|
|
34
|
+
*
|
|
35
|
+
* `encodeURI("/question?/answer")` => `"/question?/answer#section"`;
|
|
36
|
+
* `encodePath("/question?/answer#section")` => `"/question%3F/answer%23foo"`
|
|
37
|
+
*/
|
|
14
38
|
export declare function encodePath(userPath: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether `str` is a valid pathname. It must be absolute, and not contain
|
|
41
|
+
* special characters.
|
|
42
|
+
*/
|
|
15
43
|
export declare function isValidPathname(str: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve pathnames and fail-fast if resolution fails. Uses standard URL
|
|
46
|
+
* semantics (provided by `resolve-pathname` which is used internally by React
|
|
47
|
+
* router)
|
|
48
|
+
*/
|
|
16
49
|
export declare function resolvePathname(to: string, from?: string): string;
|
|
50
|
+
/** Appends a leading slash to `str`, if one doesn't exist. */
|
|
17
51
|
export declare function addLeadingSlash(str: string): string;
|
|
52
|
+
/** Appends a trailing slash to `str`, if one doesn't exist. */
|
|
18
53
|
export declare function addTrailingSlash(str: string): string;
|
|
54
|
+
/** Removes the trailing slash from `str`. */
|
|
19
55
|
export declare function removeTrailingSlash(str: string): string;
|
|
56
|
+
/** Constructs an SSH URL that can be used to push to GitHub. */
|
|
20
57
|
export declare function buildSshUrl(githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
|
|
58
|
+
/** Constructs an HTTP URL that can be used to push to GitHub. */
|
|
21
59
|
export declare function buildHttpsUrl(gitCredentials: string, githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the current URL is an SSH protocol. In addition to looking for
|
|
62
|
+
* `ssh:`, it will also allow protocol-less URLs like
|
|
63
|
+
* `git@github.com:facebook/docusaurus.git`.
|
|
64
|
+
*/
|
|
22
65
|
export declare function hasSSHProtocol(sourceRepoUrl: string): boolean;
|
|
23
66
|
//# sourceMappingURL=urlUtils.d.ts.map
|
package/lib/urlUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAoFtD;AAED,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,EACxB,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