@docusaurus/mdx-loader 2.0.0-beta.12faed89d → 2.0.0-beta.14
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/index.d.ts +24 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +168 -0
- package/lib/index.js.map +1 -0
- package/lib/remark/headings/index.d.ts +10 -0
- package/lib/remark/headings/index.d.ts.map +1 -0
- package/lib/remark/headings/index.js +61 -0
- package/lib/remark/headings/index.js.map +1 -0
- package/lib/remark/toc/index.d.ts +13 -0
- package/lib/remark/toc/index.d.ts.map +1 -0
- package/lib/remark/toc/index.js +68 -0
- package/lib/remark/toc/index.js.map +1 -0
- package/lib/remark/toc/search.d.ts +14 -0
- package/lib/remark/toc/search.d.ts.map +1 -0
- package/lib/remark/toc/search.js +67 -0
- package/lib/remark/toc/search.js.map +1 -0
- package/lib/remark/transformImage/index.d.ts +14 -0
- package/lib/remark/transformImage/index.d.ts.map +1 -0
- package/lib/remark/transformImage/index.js +91 -0
- package/lib/remark/transformImage/index.js.map +1 -0
- package/lib/remark/transformLinks/index.d.ts +15 -0
- package/lib/remark/transformLinks/index.d.ts.map +1 -0
- package/lib/remark/transformLinks/index.js +107 -0
- package/lib/remark/transformLinks/index.js.map +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.d.ts +10 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.d.ts.map +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.js +29 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.js.map +1 -0
- package/lib/remark/utils/index.d.ts +11 -0
- package/lib/remark/utils/index.d.ts.map +1 -0
- package/lib/remark/utils/index.js +40 -0
- package/lib/remark/utils/index.js.map +1 -0
- package/package.json +16 -12
- package/src/deps.d.ts +29 -0
- package/src/index.ts +216 -0
- package/src/{index.d.ts → mdx-loader.d.ts} +7 -8
- package/src/remark/headings/{index.js → index.ts} +21 -16
- package/src/remark/toc/{index.js → index.ts} +24 -16
- package/src/remark/toc/search.ts +82 -0
- package/src/remark/transformImage/{index.js → index.ts} +52 -24
- package/src/remark/transformLinks/{index.js → index.ts} +66 -44
- package/src/remark/unwrapMdxCodeBlocks/{index.js → index.ts} +11 -9
- package/src/remark/utils/index.ts +39 -0
- package/src/index.js +0 -107
- package/src/remark/headings/__tests__/index.test.js +0 -315
- package/src/remark/toc/__tests__/__snapshots__/index.test.js.snap +0 -85
- package/src/remark/toc/__tests__/fixtures/empty-headings.md +0 -5
- package/src/remark/toc/__tests__/fixtures/inline-code.md +0 -9
- package/src/remark/toc/__tests__/fixtures/insert-below-imports.md +0 -11
- package/src/remark/toc/__tests__/fixtures/just-content.md +0 -15
- package/src/remark/toc/__tests__/fixtures/name-exist.md +0 -7
- package/src/remark/toc/__tests__/fixtures/non-text-content.md +0 -9
- package/src/remark/toc/__tests__/index.test.js +0 -212
- package/src/remark/toc/search.js +0 -73
- package/src/remark/transformImage/__tests__/__snapshots__/index.test.js.snap +0 -31
- package/src/remark/transformImage/__tests__/fixtures/fail.md +0 -1
- package/src/remark/transformImage/__tests__/fixtures/img.md +0 -17
- package/src/remark/transformImage/__tests__/fixtures/img.png +0 -0
- package/src/remark/transformImage/__tests__/fixtures/noUrl.md +0 -1
- package/src/remark/transformImage/__tests__/fixtures/pathname.md +0 -1
- package/src/remark/transformImage/__tests__/index.test.js +0 -59
- package/src/remark/transformLinks/__tests__/__snapshots__/index.test.js.snap +0 -41
- package/src/remark/transformLinks/__tests__/fixtures/asset.md +0 -29
- package/src/remark/transformLinks/__tests__/fixtures/asset.pdf +0 -0
- package/src/remark/transformLinks/__tests__/fixtures/noUrl.md +0 -1
- package/src/remark/transformLinks/__tests__/fixtures/pathname.md +0 -1
- package/src/remark/transformLinks/__tests__/fixtures/static/staticAsset.pdf +0 -0
- package/src/remark/transformLinks/__tests__/fixtures/static/staticAssetImage.png +0 -0
- package/src/remark/transformLinks/__tests__/index.test.js +0 -44
- package/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.js.snap +0 -819
- package/src/remark/unwrapMdxCodeBlocks/__tests__/fixtures/has-mdx-code-blocks.mdx +0 -95
- package/src/remark/unwrapMdxCodeBlocks/__tests__/index.test.js +0 -38
- package/src/remark/utils/index.js +0 -39
- package/tsconfig.json +0 -9
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { RemarkAndRehypePluginOptions } from '@docusaurus/mdx-loader';
|
|
8
|
+
import type { LoaderContext } from 'webpack';
|
|
9
|
+
declare type Options = RemarkAndRehypePluginOptions & {
|
|
10
|
+
staticDirs: string[];
|
|
11
|
+
siteDir: string;
|
|
12
|
+
isMDXPartial?: (filePath: string) => boolean;
|
|
13
|
+
isMDXPartialFrontMatterWarningDisabled?: boolean;
|
|
14
|
+
removeContentTitle?: boolean;
|
|
15
|
+
metadataPath?: string | ((filePath: string) => string);
|
|
16
|
+
createAssets?: (metadata: {
|
|
17
|
+
frontMatter: Record<string, unknown>;
|
|
18
|
+
metadata: Record<string, unknown>;
|
|
19
|
+
}) => Record<string, unknown>;
|
|
20
|
+
filepath: string;
|
|
21
|
+
};
|
|
22
|
+
export default function mdxLoader(this: LoaderContext<Options>, fileString: string): Promise<void>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAa3C,aAAK,OAAO,GAAG,4BAA4B,GAAG;IAC5C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,sCAAsC,CAAC,EAAE,OAAO,CAAC;IACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IACvD,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE;QACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAwDF,wBAA8B,SAAS,CACrC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CA2Gf"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
const mdx_1 = (0, tslib_1.__importDefault)(require("@mdx-js/mdx"));
|
|
12
|
+
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
13
|
+
const remark_emoji_1 = (0, tslib_1.__importDefault)(require("remark-emoji"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
|
+
const stringify_object_1 = (0, tslib_1.__importDefault)(require("stringify-object"));
|
|
16
|
+
const headings_1 = (0, tslib_1.__importDefault)(require("./remark/headings"));
|
|
17
|
+
const toc_1 = (0, tslib_1.__importDefault)(require("./remark/toc"));
|
|
18
|
+
const unwrapMdxCodeBlocks_1 = (0, tslib_1.__importDefault)(require("./remark/unwrapMdxCodeBlocks"));
|
|
19
|
+
const transformImage_1 = (0, tslib_1.__importDefault)(require("./remark/transformImage"));
|
|
20
|
+
const transformLinks_1 = (0, tslib_1.__importDefault)(require("./remark/transformLinks"));
|
|
21
|
+
const { loaders: { inlineMarkdownImageFileLoader }, } = (0, utils_1.getFileLoaderUtils)();
|
|
22
|
+
const DEFAULT_OPTIONS = {
|
|
23
|
+
rehypePlugins: [],
|
|
24
|
+
remarkPlugins: [unwrapMdxCodeBlocks_1.default, remark_emoji_1.default, headings_1.default, toc_1.default],
|
|
25
|
+
beforeDefaultRemarkPlugins: [],
|
|
26
|
+
beforeDefaultRehypePlugins: [],
|
|
27
|
+
};
|
|
28
|
+
// When this throws, it generally means that there's no metadata file associated with this MDX document
|
|
29
|
+
// It can happen when using MDX partials (usually starting with _)
|
|
30
|
+
// That's why it's important to provide the "isMDXPartial" function in config
|
|
31
|
+
async function readMetadataPath(metadataPath) {
|
|
32
|
+
try {
|
|
33
|
+
return await (0, fs_extra_1.readFile)(metadataPath, 'utf8');
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new Error(`MDX loader can't read MDX metadata file for path ${metadataPath}. Maybe the isMDXPartial option function was not provided?`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Converts assets an object with Webpack require calls code
|
|
40
|
+
// This is useful for mdx files to reference co-located assets using relative paths
|
|
41
|
+
// Those assets should enter the Webpack assets pipeline and be hashed
|
|
42
|
+
// For now, we only handle that for images and paths starting with ./
|
|
43
|
+
// {image: "./myImage.png"} => {image: require("./myImage.png")}
|
|
44
|
+
function createAssetsExportCode(assets) {
|
|
45
|
+
if (Object.keys(assets).length === 0) {
|
|
46
|
+
return 'undefined';
|
|
47
|
+
}
|
|
48
|
+
// TODO implementation can be completed/enhanced
|
|
49
|
+
function createAssetValueCode(assetValue) {
|
|
50
|
+
if (Array.isArray(assetValue)) {
|
|
51
|
+
const arrayItemCodes = assetValue.map((item) => { var _a; return (_a = createAssetValueCode(item)) !== null && _a !== void 0 ? _a : 'undefined'; });
|
|
52
|
+
return `[${arrayItemCodes.join(', ')}]`;
|
|
53
|
+
}
|
|
54
|
+
// Only process string values starting with ./
|
|
55
|
+
// We could enhance this logic and check if file exists on disc?
|
|
56
|
+
if (typeof assetValue === 'string' && assetValue.startsWith('./')) {
|
|
57
|
+
// TODO do we have other use-cases than image assets?
|
|
58
|
+
// Probably not worth adding more support, as we want to move to Webpack 5 new asset system (https://github.com/facebook/docusaurus/pull/4708)
|
|
59
|
+
const inlineLoader = inlineMarkdownImageFileLoader;
|
|
60
|
+
return `require("${inlineLoader}${(0, utils_1.escapePath)(assetValue)}").default`;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const assetEntries = Object.entries(assets);
|
|
65
|
+
const codeLines = assetEntries
|
|
66
|
+
.map(([key, value]) => {
|
|
67
|
+
const assetRequireCode = createAssetValueCode(value);
|
|
68
|
+
return assetRequireCode ? `"${key}": ${assetRequireCode},` : undefined;
|
|
69
|
+
})
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
return `{\n${codeLines.join('\n')}\n}`;
|
|
72
|
+
}
|
|
73
|
+
async function mdxLoader(fileString) {
|
|
74
|
+
const callback = this.async();
|
|
75
|
+
const filePath = this.resourcePath;
|
|
76
|
+
const reqOptions = this.getOptions() || {};
|
|
77
|
+
const { frontMatter, content: contentWithTitle } = (0, utils_1.parseFrontMatter)(fileString);
|
|
78
|
+
const { content, contentTitle } = (0, utils_1.parseMarkdownContentTitle)(contentWithTitle, {
|
|
79
|
+
removeContentTitle: reqOptions.removeContentTitle,
|
|
80
|
+
});
|
|
81
|
+
const hasFrontMatter = Object.keys(frontMatter).length > 0;
|
|
82
|
+
const options = {
|
|
83
|
+
...reqOptions,
|
|
84
|
+
remarkPlugins: [
|
|
85
|
+
...(reqOptions.beforeDefaultRemarkPlugins || []),
|
|
86
|
+
...DEFAULT_OPTIONS.remarkPlugins,
|
|
87
|
+
[transformImage_1.default, { staticDirs: reqOptions.staticDirs, filePath }],
|
|
88
|
+
[
|
|
89
|
+
transformLinks_1.default,
|
|
90
|
+
{
|
|
91
|
+
staticDirs: reqOptions.staticDirs,
|
|
92
|
+
filePath,
|
|
93
|
+
siteDir: reqOptions.siteDir,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
...(reqOptions.remarkPlugins || []),
|
|
97
|
+
],
|
|
98
|
+
rehypePlugins: [
|
|
99
|
+
...(reqOptions.beforeDefaultRehypePlugins || []),
|
|
100
|
+
...DEFAULT_OPTIONS.rehypePlugins,
|
|
101
|
+
...(reqOptions.rehypePlugins || []),
|
|
102
|
+
],
|
|
103
|
+
filepath: filePath,
|
|
104
|
+
};
|
|
105
|
+
let result;
|
|
106
|
+
try {
|
|
107
|
+
result = await (0, mdx_1.default)(content, options);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return callback(err);
|
|
111
|
+
}
|
|
112
|
+
// MDX partials are MDX files starting with _ or in a folder starting with _
|
|
113
|
+
// Partial are not expected to have an associated metadata file or frontmatter
|
|
114
|
+
const isMDXPartial = options.isMDXPartial && options.isMDXPartial(filePath);
|
|
115
|
+
if (isMDXPartial && hasFrontMatter) {
|
|
116
|
+
const errorMessage = `Docusaurus MDX partial files should not contain FrontMatter.
|
|
117
|
+
Those partial files use the _ prefix as a convention by default, but this is configurable.
|
|
118
|
+
File at ${filePath} contains FrontMatter that will be ignored:
|
|
119
|
+
${JSON.stringify(frontMatter, null, 2)}`;
|
|
120
|
+
if (!options.isMDXPartialFrontMatterWarningDisabled) {
|
|
121
|
+
const shouldError = process.env.NODE_ENV === 'test' || process.env.CI;
|
|
122
|
+
if (shouldError) {
|
|
123
|
+
return callback(new Error(errorMessage));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
logger_1.default.warn(errorMessage);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function getMetadataPath() {
|
|
131
|
+
if (!isMDXPartial) {
|
|
132
|
+
// Read metadata for this MDX and export it.
|
|
133
|
+
if (options.metadataPath && typeof options.metadataPath === 'function') {
|
|
134
|
+
return options.metadataPath(filePath);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const metadataPath = getMetadataPath();
|
|
140
|
+
if (metadataPath) {
|
|
141
|
+
this.addDependency(metadataPath);
|
|
142
|
+
}
|
|
143
|
+
const metadataJsonString = metadataPath
|
|
144
|
+
? await readMetadataPath(metadataPath)
|
|
145
|
+
: undefined;
|
|
146
|
+
const metadata = metadataJsonString
|
|
147
|
+
? JSON.parse(metadataJsonString)
|
|
148
|
+
: undefined;
|
|
149
|
+
const assets = reqOptions.createAssets && metadata
|
|
150
|
+
? reqOptions.createAssets({ frontMatter, metadata })
|
|
151
|
+
: undefined;
|
|
152
|
+
const exportsCode = `
|
|
153
|
+
export const frontMatter = ${(0, stringify_object_1.default)(frontMatter)};
|
|
154
|
+
export const contentTitle = ${(0, stringify_object_1.default)(contentTitle)};
|
|
155
|
+
${metadataJsonString ? `export const metadata = ${metadataJsonString};` : ''}
|
|
156
|
+
${assets ? `export const assets = ${createAssetsExportCode(assets)};` : ''}
|
|
157
|
+
`;
|
|
158
|
+
const code = `
|
|
159
|
+
import React from 'react';
|
|
160
|
+
import { mdx } from '@mdx-js/react';
|
|
161
|
+
|
|
162
|
+
${exportsCode}
|
|
163
|
+
${result}
|
|
164
|
+
`;
|
|
165
|
+
return callback(null, code);
|
|
166
|
+
}
|
|
167
|
+
exports.default = mdxLoader;
|
|
168
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAkC;AAClC,mEAA8B;AAC9B,6EAAwC;AACxC,6EAAiC;AACjC,6CAK2B;AAC3B,qFAA+C;AAC/C,8EAAyC;AACzC,oEAA+B;AAC/B,oGAA+D;AAC/D,0FAAqD;AACrD,0FAAqD;AAIrD,MAAM,EACJ,OAAO,EAAE,EAAC,6BAA6B,EAAC,GACzC,GAAG,IAAA,0BAAkB,GAAE,CAAC;AAEzB,MAAM,eAAe,GAAiC;IACpD,aAAa,EAAE,EAAE;IACjB,aAAa,EAAE,CAAC,6BAAmB,EAAE,sBAAK,EAAE,kBAAQ,EAAE,aAAG,CAAC;IAC1D,0BAA0B,EAAE,EAAE;IAC9B,0BAA0B,EAAE,EAAE;CAC/B,CAAC;AAgBF,uGAAuG;AACvG,kEAAkE;AAClE,6EAA6E;AAC7E,KAAK,UAAU,gBAAgB,CAAC,YAAoB;IAClD,IAAI;QACF,OAAO,MAAM,IAAA,mBAAQ,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,oDAAoD,YAAY,4DAA4D,CAC7H,CAAC;KACH;AACH,CAAC;AAED,4DAA4D;AAC5D,mFAAmF;AACnF,sEAAsE;AACtE,qEAAqE;AACrE,gEAAgE;AAChE,SAAS,sBAAsB,CAAC,MAA+B;IAC7D,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACpC,OAAO,WAAW,CAAC;KACpB;IAED,gDAAgD;IAChD,SAAS,oBAAoB,CAAC,UAAmB;QAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC7B,MAAM,cAAc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6BACO,IAAA,0BAAe,EAAC,WAAW,CAAC;8BAC3B,IAAA,0BAAe,EAAC,YAAY,CAAC;EACzD,kBAAkB,CAAC,CAAC,CAAC,2BAA2B,kBAAkB,GAAG,CAAC,CAAC,CAAC,EAAE;EAC1E,MAAM,CAAC,CAAC,CAAC,yBAAyB,sBAAsB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;CACzE,CAAC;IAEA,MAAM,IAAI,GAAG;;;;EAIb,WAAW;EACX,MAAM;CACP,CAAC;IAEA,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AA9GD,4BA8GC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { Transformer } from 'unified';
|
|
8
|
+
declare function headings(): Transformer;
|
|
9
|
+
export default headings;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAIzC,iBAAS,QAAQ,IAAI,WAAW,CA4D/B;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
/* Based on remark-slug (https://github.com/remarkjs/remark-slug) and gatsby-remark-autolink-headers (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-autolink-headers) */
|
|
11
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
|
+
const unist_util_visit_1 = (0, tslib_1.__importDefault)(require("unist-util-visit"));
|
|
13
|
+
const mdast_util_to_string_1 = (0, tslib_1.__importDefault)(require("mdast-util-to-string"));
|
|
14
|
+
function headings() {
|
|
15
|
+
const transformer = (ast) => {
|
|
16
|
+
const slugs = (0, utils_1.createSlugger)();
|
|
17
|
+
const visitor = (headingNode) => {
|
|
18
|
+
const data = headingNode.data || (headingNode.data = {});
|
|
19
|
+
const properties = (data.hProperties || (data.hProperties = {}));
|
|
20
|
+
let { id } = properties;
|
|
21
|
+
if (id) {
|
|
22
|
+
id = slugs.slug(id, { maintainCase: true });
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const headingTextNodes = headingNode.children.filter(({ type }) => !['html', 'jsx'].includes(type));
|
|
26
|
+
const heading = (0, mdast_util_to_string_1.default)(headingTextNodes.length > 0
|
|
27
|
+
? { children: headingTextNodes }
|
|
28
|
+
: headingNode);
|
|
29
|
+
// Support explicit heading IDs
|
|
30
|
+
const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(heading);
|
|
31
|
+
id = parsedHeading.id || slugs.slug(heading);
|
|
32
|
+
if (parsedHeading.id) {
|
|
33
|
+
// When there's an id, it is always in the last child node
|
|
34
|
+
// Sometimes heading is in multiple "parts" (** syntax creates a child node):
|
|
35
|
+
// ## part1 *part2* part3 {#id}
|
|
36
|
+
const lastNode = headingNode.children[headingNode.children.length - 1];
|
|
37
|
+
if (headingNode.children.length > 1) {
|
|
38
|
+
const lastNodeText = (0, utils_1.parseMarkdownHeadingId)(lastNode.value).text;
|
|
39
|
+
// When last part contains test+id, remove the id
|
|
40
|
+
if (lastNodeText) {
|
|
41
|
+
lastNode.value = lastNodeText;
|
|
42
|
+
}
|
|
43
|
+
// When last part contains only the id: completely remove that node
|
|
44
|
+
else {
|
|
45
|
+
headingNode.children.pop();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
lastNode.value = parsedHeading.text;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
data.id = id;
|
|
54
|
+
properties.id = id;
|
|
55
|
+
};
|
|
56
|
+
(0, unist_util_visit_1.default)(ast, 'heading', visitor);
|
|
57
|
+
};
|
|
58
|
+
return transformer;
|
|
59
|
+
}
|
|
60
|
+
exports.default = headings;
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/headings/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,gMAAgM;AAEhM,6CAAwE;AACxE,qFAAgD;AAChD,6FAA4C;AAK5C,SAAS,QAAQ;IACf,MAAM,WAAW,GAAgB,CAAC,GAAG,EAAE,EAAE;QACvC,MAAM,KAAK,GAAG,IAAA,qBAAa,GAAE,CAAC;QAE9B,MAAM,OAAO,GAAqB,CAAC,WAAW,EAAE,EAAE;YAChD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;YACzD,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,CAE9D,CAAC;YACF,IAAI,EAAC,EAAE,EAAC,GAAG,UAAU,CAAC;YAEtB,IAAI,EAAE,EAAE;gBACN,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC;aAC3C;iBAAM;gBACL,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAClD,CAAC,EAAC,IAAI,EAAC,EAAE,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O,WAAW,CAAC;AACrB,CAAC;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
interface PluginOptions {
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const plugin: Plugin<[PluginOptions?]>;
|
|
12
|
+
export default plugin;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AAajD,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAyCD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAgBpC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const parser_1 = require("@babel/parser");
|
|
11
|
+
const traverse_1 = (0, tslib_1.__importDefault)(require("@babel/traverse"));
|
|
12
|
+
const stringify_object_1 = (0, tslib_1.__importDefault)(require("stringify-object"));
|
|
13
|
+
const search_1 = (0, tslib_1.__importDefault)(require("./search"));
|
|
14
|
+
const parseOptions = {
|
|
15
|
+
plugins: ['jsx'],
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
};
|
|
18
|
+
const isImport = (child) => child.type === 'import';
|
|
19
|
+
const hasImports = (index) => index > -1;
|
|
20
|
+
const isExport = (child) => child.type === 'export';
|
|
21
|
+
const isTarget = (child, name) => {
|
|
22
|
+
let found = false;
|
|
23
|
+
const ast = (0, parser_1.parse)(child.value, parseOptions);
|
|
24
|
+
(0, traverse_1.default)(ast, {
|
|
25
|
+
VariableDeclarator: (path) => {
|
|
26
|
+
if (path.node.id.name === name) {
|
|
27
|
+
found = true;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return found;
|
|
32
|
+
};
|
|
33
|
+
const getOrCreateExistingTargetIndex = (children, name) => {
|
|
34
|
+
let importsIndex = -1;
|
|
35
|
+
let targetIndex = -1;
|
|
36
|
+
children.forEach((child, index) => {
|
|
37
|
+
if (isImport(child)) {
|
|
38
|
+
importsIndex = index;
|
|
39
|
+
}
|
|
40
|
+
else if (isExport(child) && isTarget(child, name)) {
|
|
41
|
+
targetIndex = index;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (targetIndex === -1) {
|
|
45
|
+
const target = {
|
|
46
|
+
default: false,
|
|
47
|
+
type: 'export',
|
|
48
|
+
value: `export const ${name} = [];`,
|
|
49
|
+
};
|
|
50
|
+
targetIndex = hasImports(importsIndex) ? importsIndex + 1 : 0;
|
|
51
|
+
children.splice(targetIndex, 0, target);
|
|
52
|
+
}
|
|
53
|
+
return targetIndex;
|
|
54
|
+
};
|
|
55
|
+
const plugin = (options = {}) => {
|
|
56
|
+
const name = options.name || 'toc';
|
|
57
|
+
const transformer = (node) => {
|
|
58
|
+
const headings = (0, search_1.default)(node);
|
|
59
|
+
const { children } = node;
|
|
60
|
+
const targetIndex = getOrCreateExistingTargetIndex(children, name);
|
|
61
|
+
if (headings && headings.length) {
|
|
62
|
+
children[targetIndex].value = `export const ${name} = ${(0, stringify_object_1.default)(headings)};`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return transformer;
|
|
66
|
+
};
|
|
67
|
+
exports.default = plugin;
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/toc/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,0CAAmD;AAEnD,4EAAuC;AACvC,qFAA+C;AAC/C,mEAA8B;AAK9B,MAAM,YAAY,GAAkB;IAClC,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAW,EAAoB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC5E,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,CAAC,KAAW,EAAoB,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAM5E,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAE,IAAY,EAAE,EAAE;IAChD,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,GAAG,GAAG,IAAA,cAAK,EAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC7C,IAAA,kBAAQ,EAAC,GAAG,EAAE;QACZ,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAK,IAAI,CAAC,IAAI,CAAC,EAAiB,CAAC,IAAI,KAAK,IAAI,EAAE;gBAC9C,KAAK,GAAG,IAAI,CAAC;aACd;QACH,CAAC;KACF,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,8BAA8B,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAE,EAAE;IACxE,IAAI,Y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AAM,IAAA,0BAAe,EACrE,QAAQ,CACT,GAAG,CAAC;SACN;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { TOCItem } from '@docusaurus/types';
|
|
8
|
+
import type { Node } from 'unist';
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Generate a TOC AST from the raw Markdown contents
|
|
12
|
+
*/
|
|
13
|
+
export default function search(node: Node): TOCItem[];
|
|
14
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/remark/toc/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAUhC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,EAAE,CAwDpD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const mdast_util_to_string_1 = (0, tslib_1.__importDefault)(require("mdast-util-to-string"));
|
|
11
|
+
const unist_util_visit_1 = (0, tslib_1.__importDefault)(require("unist-util-visit"));
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Generate a TOC AST from the raw Markdown contents
|
|
16
|
+
*/
|
|
17
|
+
function search(node) {
|
|
18
|
+
const headings = [];
|
|
19
|
+
const visitor = (child, _index, parent) => {
|
|
20
|
+
const value = (0, mdast_util_to_string_1.default)(child);
|
|
21
|
+
// depth:1 headings are titles and not included in the TOC
|
|
22
|
+
if (parent !== node || !value || child.depth < 2) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
headings.push({
|
|
26
|
+
node: {
|
|
27
|
+
value: (0, utils_1.toValue)(child),
|
|
28
|
+
id: child.data.id,
|
|
29
|
+
children: [],
|
|
30
|
+
level: child.depth,
|
|
31
|
+
},
|
|
32
|
+
level: child.depth,
|
|
33
|
+
parentIndex: -1,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
(0, unist_util_visit_1.default)(node, 'heading', visitor);
|
|
37
|
+
// Keep track of which previous index would be the current heading's direcy parent.
|
|
38
|
+
// Each entry <i> is the last index of the `headings` array at heading level <i>.
|
|
39
|
+
// We will modify these indices as we iterate through all headings.
|
|
40
|
+
// e.g. if an ### H3 was last seen at index 2, then prevIndexForLevel[3] === 2
|
|
41
|
+
// indices 0 and 1 will remain unused.
|
|
42
|
+
const prevIndexForLevel = Array(7).fill(-1);
|
|
43
|
+
headings.forEach((curr, currIndex) => {
|
|
44
|
+
// take the last seen index for each ancestor level. the highest
|
|
45
|
+
// index will be the direct ancestor of the current heading.
|
|
46
|
+
const ancestorLevelIndexes = prevIndexForLevel.slice(2, curr.level);
|
|
47
|
+
curr.parentIndex = Math.max(...ancestorLevelIndexes);
|
|
48
|
+
// mark that curr.level was last seen at the current index
|
|
49
|
+
prevIndexForLevel[curr.level] = currIndex;
|
|
50
|
+
});
|
|
51
|
+
const rootNodeIndexes = [];
|
|
52
|
+
// For a given parentIndex, add each Node into that parent's `children` array
|
|
53
|
+
headings.forEach((heading, i) => {
|
|
54
|
+
if (heading.parentIndex >= 0) {
|
|
55
|
+
headings[heading.parentIndex].node.children.push(heading.node);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
rootNodeIndexes.push(i);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const toc = headings
|
|
62
|
+
.filter((_, k) => rootNodeIndexes.includes(k)) // only return root nodes
|
|
63
|
+
.map((heading) => heading.node); // only return Node, no metadata
|
|
64
|
+
return toc;
|
|
65
|
+
}
|
|
66
|
+
exports.default = search;
|
|
67
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/remark/toc/search.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6FAA4C;AAC5C,qFAAgD;AAChD,oCAAiC;AAYjC;;;GAGG;AACH,SAAwB,MAAM,CAAC,IAAU;IACvC,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAElC,MAAM,OAAO,GAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAC1D,MAAM,KAAK,GAAG,IAAA,8BAAQ,EAAC,KAAK,CAAC,CAAC;QAE9B,0DAA0D;QAC1D,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE;YAChD,OAAO;SACR;QAED,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE;gBACJ,KAAK,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC;gBACrB,EAAE,EAAE,KAAK,CAAC,IAAK,CAAC,EAAY;gBAC5B,QAAQ,EAAE,EAAE;gBACZ,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB;YACD,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,WAAW,EAAE,CAAC,CAAC;SAChB,CAAC,CAAC;IACL,CAAC,C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;IACnE,OAAO,GAAG,CAAC;AACb,CAAC;AAxDD,yBAwDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
interface PluginOptions {
|
|
9
|
+
filePath: string;
|
|
10
|
+
staticDirs: string[];
|
|
11
|
+
}
|
|
12
|
+
declare const plugin: Plugin<[PluginOptions]>;
|
|
13
|
+
export default plugin;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AAOjD,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AA8FD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,CASnC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const unist_util_visit_1 = (0, tslib_1.__importDefault)(require("unist-util-visit"));
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const url_1 = (0, tslib_1.__importDefault)(require("url"));
|
|
13
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
14
|
+
const escape_html_1 = (0, tslib_1.__importDefault)(require("escape-html"));
|
|
15
|
+
const utils_1 = require("@docusaurus/utils");
|
|
16
|
+
const { loaders: { inlineMarkdownImageFileLoader }, } = (0, utils_1.getFileLoaderUtils)();
|
|
17
|
+
const createJSX = (node, pathUrl) => {
|
|
18
|
+
const jsxNode = node;
|
|
19
|
+
jsxNode.type = 'jsx';
|
|
20
|
+
jsxNode.value = `<img ${node.alt ? `alt={"${(0, escape_html_1.default)(node.alt)}"} ` : ''}${node.url
|
|
21
|
+
? `src={require("${inlineMarkdownImageFileLoader}${(0, utils_1.escapePath)(pathUrl)}").default}`
|
|
22
|
+
: ''}${node.title ? ` title="${(0, escape_html_1.default)(node.title)}"` : ''} />`;
|
|
23
|
+
if (jsxNode.url) {
|
|
24
|
+
delete jsxNode.url;
|
|
25
|
+
}
|
|
26
|
+
if (jsxNode.alt) {
|
|
27
|
+
delete jsxNode.alt;
|
|
28
|
+
}
|
|
29
|
+
if (jsxNode.title) {
|
|
30
|
+
delete jsxNode.title;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
async function ensureImageFileExist(imagePath, sourceFilePath) {
|
|
34
|
+
const imageExists = await fs_extra_1.default.pathExists(imagePath);
|
|
35
|
+
if (!imageExists) {
|
|
36
|
+
throw new Error(`Image ${(0, utils_1.toMessageRelativeFilePath)(imagePath)} used in ${(0, utils_1.toMessageRelativeFilePath)(sourceFilePath)} not found.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function findImage(possiblePaths, sourceFilePath) {
|
|
40
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
41
|
+
for (const possiblePath of possiblePaths) {
|
|
42
|
+
if (await fs_extra_1.default.pathExists(possiblePath)) {
|
|
43
|
+
return possiblePath;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Image ${possiblePaths
|
|
47
|
+
.map((p) => (0, utils_1.toMessageRelativeFilePath)(p))
|
|
48
|
+
.join(' or ')} used in ${(0, utils_1.toMessageRelativeFilePath)(sourceFilePath)} not found.`);
|
|
49
|
+
}
|
|
50
|
+
async function processImageNode(node, { filePath, staticDirs }) {
|
|
51
|
+
if (!node.url) {
|
|
52
|
+
throw new Error(`Markdown image URL is mandatory in "${(0, utils_1.toMessageRelativeFilePath)(filePath)}" file`);
|
|
53
|
+
}
|
|
54
|
+
const parsedUrl = url_1.default.parse(node.url);
|
|
55
|
+
if (parsedUrl.protocol) {
|
|
56
|
+
// pathname:// is an escape hatch,
|
|
57
|
+
// in case user does not want his images to be converted to require calls going through webpack loader
|
|
58
|
+
// we don't have to document this for now,
|
|
59
|
+
// it's mostly to make next release less risky (2.0.0-alpha.59)
|
|
60
|
+
if (parsedUrl.protocol === 'pathname:') {
|
|
61
|
+
node.url = node.url.replace('pathname://', '');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// images without protocol
|
|
65
|
+
else if (path_1.default.isAbsolute(node.url)) {
|
|
66
|
+
// absolute paths are expected to exist in the static folder
|
|
67
|
+
const possibleImagePaths = staticDirs.map((dir) => path_1.default.join(dir, node.url));
|
|
68
|
+
const imagePath = await findImage(possibleImagePaths, filePath);
|
|
69
|
+
createJSX(node, (0, utils_1.posixPath)(imagePath));
|
|
70
|
+
}
|
|
71
|
+
// We try to convert image urls without protocol to images with require calls
|
|
72
|
+
// going through webpack ensures that image assets exist at build time
|
|
73
|
+
else {
|
|
74
|
+
// relative paths are resolved against the source file's folder
|
|
75
|
+
const expectedImagePath = path_1.default.join(path_1.default.dirname(filePath), node.url);
|
|
76
|
+
await ensureImageFileExist(expectedImagePath, filePath);
|
|
77
|
+
createJSX(node, node.url.startsWith('./') ? node.url : `./${node.url}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const plugin = (options) => {
|
|
81
|
+
const transformer = async (root) => {
|
|
82
|
+
const promises = [];
|
|
83
|
+
(0, unist_util_visit_1.default)(root, 'image', (node) => {
|
|
84
|
+
promises.push(processImageNode(node, options));
|
|
85
|
+
});
|
|
86
|
+
await Promise.all(promises);
|
|
87
|
+
};
|
|
88
|
+
return transformer;
|
|
89
|
+
};
|
|
90
|
+
exports.default = plugin;
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/remark/transformImage/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qFAAqC;AACrC,6DAAwB;AACxB,2DAAsB;AACtB,qEAA0B;AAC1B,2EAAqC;AACrC,6CAK2B;AAI3B,MAAM,EACJ,OAAO,EAAE,EAAC,6BAA6B,EAAC,GACzC,GAAG,IAAA,0BAAkB,GAAE,CAAC;AAOzB,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,OAAe,EAAE,EAAE;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC;IACpB,OAA8B,CAAC,IAAI,GAAG,KAAK,CAAC;IAC5C,OAA8B,CAAC,KAAK,GAAG,QACtC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,IAAA,qBAAU,EAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAClD,GACE,IAAI,CAAC,GAAG;QACN,CAAC,CAAC,iBAAiB,6BAA6B,GAAG,IAAA,kBAAU,EACzD,OAAO,CACR,aAAa;QAChB,CAAC,CAAC,EACN,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,IAAA,qBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IAE/D,IAAI,OAAO,CAAC,GAAG,EAAE;QACf,OAAQ,OAA0B,CAAC,GAAG,CAAC;KACxC;IACD,IAAI,OAAO,CAAC,GAAG,EAAE;QACf,OAAO,OAAO,CAAC,GAAG,CAAC;KACpB;IACD,I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AAC,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin } from 'unified';
|
|
8
|
+
interface PluginOptions {
|
|
9
|
+
filePath: string;
|
|
10
|
+
staticDirs: string[];
|
|
11
|
+
siteDir: string;
|
|
12
|
+
}
|
|
13
|
+
declare const plugin: Plugin<[PluginOptions]>;
|
|
14
|
+
export default plugin;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/remark/transformLinks/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EAAC,MAAM,EAAc,MAAM,SAAS,CAAC;AAQjD,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0HD,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,CASnC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|