@docusaurus/utils 2.0.0-beta.8bda3b2db → 2.0.0-beta.9
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/.tsbuildinfo +1 -1
- package/lib/codeTranslationsUtils.js +2 -2
- package/lib/globUtils.d.ts +11 -0
- package/lib/globUtils.js +47 -0
- package/lib/{docuHash.d.ts → hashUtils.d.ts} +2 -0
- package/lib/{docuHash.js → hashUtils.js} +15 -5
- package/lib/index.d.ts +5 -4
- package/lib/index.js +38 -88
- package/lib/markdownLinks.js +19 -6
- package/lib/markdownParser.js +20 -12
- package/lib/mdxUtils.d.ts +16 -0
- package/lib/mdxUtils.js +30 -0
- package/lib/{getFilePathForRoutePath.d.ts → normalizeUrl.d.ts} +1 -1
- package/lib/normalizeUrl.js +66 -0
- package/lib/pathUtils.d.ts +0 -1
- package/lib/pathUtils.js +1 -6
- package/lib/tags.d.ts +18 -0
- package/lib/tags.js +72 -0
- package/package.json +17 -6
- package/src/__tests__/globUtils.test.ts +109 -0
- package/src/__tests__/{docuHash.test.ts → hashUtils.test.ts} +22 -1
- package/src/__tests__/index.test.ts +0 -108
- package/src/__tests__/markdownParser.test.ts +13 -0
- package/src/__tests__/mdxUtils.test.ts +133 -0
- package/src/__tests__/normalizeUrl.test.ts +117 -0
- package/src/__tests__/pathUtils.test.ts +5 -22
- package/src/__tests__/tags.test.ts +183 -0
- package/src/dependencies.d.ts +12 -0
- package/src/globUtils.ts +63 -0
- package/src/{docuHash.ts → hashUtils.ts} +10 -1
- package/src/index.ts +14 -83
- package/src/markdownLinks.ts +19 -8
- package/src/markdownParser.ts +24 -17
- package/src/mdxUtils.ts +32 -0
- package/src/normalizeUrl.ts +80 -0
- package/src/pathUtils.ts +0 -6
- package/src/tags.ts +100 -0
- package/src/types.d.ts +10 -0
- package/yarn-error.log +17862 -0
- package/lib/getFilePathForRoutePath.js +0 -40
- package/src/__tests__/getFilePathForRoutePath.test.ts +0 -87
- package/src/getFilePathForRoutePath.ts +0 -43
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
exports.getFilePathForRoutePath = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
/*
|
|
13
|
-
export function getFilePathForRoutePath(routePath: string): string {
|
|
14
|
-
const fileName = path.basename(routePath);
|
|
15
|
-
const filePath = path.dirname(routePath);
|
|
16
|
-
return path.join(filePath, `${fileName}/index.html`);
|
|
17
|
-
}
|
|
18
|
-
*/
|
|
19
|
-
// Almost exact copy of the behavior we implemented in our Docusaurus fork of the webpack static gen plugin
|
|
20
|
-
// See https://github.com/slorber/static-site-generator-webpack-plugin/blob/master/index.js#L167
|
|
21
|
-
function getFilePathForRoutePath(routePath, trailingSlash) {
|
|
22
|
-
// const outputFileName = routePath.replace(/^(\/|\\)/, ''); // Remove leading slashes for webpack-dev-server
|
|
23
|
-
// Paths ending with .html are left untouched
|
|
24
|
-
if (/\.(html?)$/i.test(routePath)) {
|
|
25
|
-
return routePath;
|
|
26
|
-
}
|
|
27
|
-
// Legacy retro-compatible behavior
|
|
28
|
-
if (typeof trailingSlash === 'undefined') {
|
|
29
|
-
return path_1.default.join(routePath, 'index.html');
|
|
30
|
-
}
|
|
31
|
-
// New behavior: we can say if we prefer file/folder output
|
|
32
|
-
// Useful resource: https://github.com/slorber/trailing-slash-guide
|
|
33
|
-
if (routePath === '' || routePath.endsWith('/') || trailingSlash) {
|
|
34
|
-
return path_1.default.join(routePath, 'index.html');
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return `${routePath}.html`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.getFilePathForRoutePath = getFilePathForRoutePath;
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
import {getFilePathForRoutePath} from '../getFilePathForRoutePath';
|
|
9
|
-
import {posixPath} from '../posixPath';
|
|
10
|
-
|
|
11
|
-
describe('getFilePathForRoutePath trailingSlash=undefined', () => {
|
|
12
|
-
test('works for /', () => {
|
|
13
|
-
expect(posixPath(getFilePathForRoutePath('/', undefined))).toEqual(
|
|
14
|
-
'/index.html',
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('works for /somePath', () => {
|
|
19
|
-
expect(posixPath(getFilePathForRoutePath('/somePath', undefined))).toEqual(
|
|
20
|
-
'/somePath/index.html',
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('works for /somePath/', () => {
|
|
25
|
-
expect(posixPath(getFilePathForRoutePath('/somePath/', undefined))).toEqual(
|
|
26
|
-
'/somePath/index.html',
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('works for /somePath/xyz.html', () => {
|
|
31
|
-
expect(
|
|
32
|
-
posixPath(getFilePathForRoutePath('/somePath/xyz.html', undefined)),
|
|
33
|
-
).toEqual('/somePath/xyz.html');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('getFilePathForRoutePath trailingSlash=true', () => {
|
|
38
|
-
test('works for /', () => {
|
|
39
|
-
expect(posixPath(getFilePathForRoutePath('/', true))).toEqual(
|
|
40
|
-
'/index.html',
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('works for /somePath', () => {
|
|
45
|
-
expect(posixPath(getFilePathForRoutePath('/somePath', true))).toEqual(
|
|
46
|
-
'/somePath/index.html',
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('works for /somePath/', () => {
|
|
51
|
-
expect(posixPath(getFilePathForRoutePath('/somePath/', true))).toEqual(
|
|
52
|
-
'/somePath/index.html',
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('works for /somePath/xyz.html', () => {
|
|
57
|
-
expect(
|
|
58
|
-
posixPath(getFilePathForRoutePath('/somePath/xyz.html', true)),
|
|
59
|
-
).toEqual('/somePath/xyz.html');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('getFilePathForRoutePath trailingSlash=false', () => {
|
|
64
|
-
test('works for /', () => {
|
|
65
|
-
expect(posixPath(getFilePathForRoutePath('/', false))).toEqual(
|
|
66
|
-
'/index.html',
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('works for /somePath', () => {
|
|
71
|
-
expect(posixPath(getFilePathForRoutePath('/somePath', false))).toEqual(
|
|
72
|
-
'/somePath.html',
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('works for /somePath/', () => {
|
|
77
|
-
expect(posixPath(getFilePathForRoutePath('/somePath/', false))).toEqual(
|
|
78
|
-
'/somePath/index.html',
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('works for /somePath/xyz.html', () => {
|
|
83
|
-
expect(
|
|
84
|
-
posixPath(getFilePathForRoutePath('/somePath/xyz.html', false)),
|
|
85
|
-
).toEqual('/somePath/xyz.html');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
import path from 'path';
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
export function getFilePathForRoutePath(routePath: string): string {
|
|
12
|
-
const fileName = path.basename(routePath);
|
|
13
|
-
const filePath = path.dirname(routePath);
|
|
14
|
-
return path.join(filePath, `${fileName}/index.html`);
|
|
15
|
-
}
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// Almost exact copy of the behavior we implemented in our Docusaurus fork of the webpack static gen plugin
|
|
19
|
-
// See https://github.com/slorber/static-site-generator-webpack-plugin/blob/master/index.js#L167
|
|
20
|
-
export function getFilePathForRoutePath(
|
|
21
|
-
routePath: string,
|
|
22
|
-
trailingSlash: boolean | undefined,
|
|
23
|
-
): string {
|
|
24
|
-
// const outputFileName = routePath.replace(/^(\/|\\)/, ''); // Remove leading slashes for webpack-dev-server
|
|
25
|
-
|
|
26
|
-
// Paths ending with .html are left untouched
|
|
27
|
-
if (/\.(html?)$/i.test(routePath)) {
|
|
28
|
-
return routePath;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Legacy retro-compatible behavior
|
|
32
|
-
if (typeof trailingSlash === 'undefined') {
|
|
33
|
-
return path.join(routePath, 'index.html');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// New behavior: we can say if we prefer file/folder output
|
|
37
|
-
// Useful resource: https://github.com/slorber/trailing-slash-guide
|
|
38
|
-
if (routePath === '' || routePath.endsWith('/') || trailingSlash) {
|
|
39
|
-
return path.join(routePath, 'index.html');
|
|
40
|
-
} else {
|
|
41
|
-
return `${routePath}.html`;
|
|
42
|
-
}
|
|
43
|
-
}
|