@brillout/docpress 0.15.10-commit-ef0b9a0 → 0.15.10-commit-e9efbd3
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/components/CodeSnippets.tsx +5 -1
- package/detypePlugin.ts +49 -20
- package/dist/+config.js +1 -1
- package/dist/NavItemComponent.js +46 -38
- package/dist/components/CodeBlockTransformer.js +3 -2
- package/dist/components/CodeSnippets.js +83 -21
- package/dist/components/Comment.js +2 -1
- package/dist/components/FileRemoved.js +6 -4
- package/dist/components/HorizontalLine.js +2 -1
- package/dist/components/ImportMeta.js +3 -2
- package/dist/components/Link.js +50 -34
- package/dist/components/Note.js +29 -17
- package/dist/components/P.js +12 -1
- package/dist/components/RepoLink.js +9 -7
- package/dist/determineNavItemsColumnLayout.js +62 -48
- package/dist/detypePlugin.js +127 -40
- package/dist/parseMarkdownMini.js +17 -5
- package/dist/parsePageSections.js +82 -41
- package/dist/renderer/usePageContext.js +7 -6
- package/dist/resolvePageContext.js +103 -91
- package/dist/utils/Emoji/Emoji.js +21 -13
- package/dist/utils/assert.js +16 -14
- package/dist/utils/cls.js +1 -1
- package/dist/utils/determineSectionUrlHash.js +5 -5
- package/dist/utils/filter.js +2 -2
- package/dist/utils/getGlobalObject.js +3 -3
- package/dist/utils/useSelectedLanguage.js +12 -11
- package/dist/vite.config.js +7 -7
- package/package.json +2 -2
- package/tsconfig.json +0 -1
package/dist/utils/cls.js
CHANGED
|
@@ -4,7 +4,7 @@ export { determineSectionTitle };
|
|
|
4
4
|
function determineSectionUrlHash(title) {
|
|
5
5
|
title = title.toLowerCase();
|
|
6
6
|
title = removeAccentsAndDiacritics(title);
|
|
7
|
-
|
|
7
|
+
var urlHash = title
|
|
8
8
|
// \u4E00-\u9FA5 are chinese characters, see https://github.com/brillout/docpress/pull/2
|
|
9
9
|
.split(/[^a-z0-9\u4E00-\u9FA5]+/)
|
|
10
10
|
.filter(Boolean)
|
|
@@ -20,11 +20,11 @@ function removeAccentsAndDiacritics(str) {
|
|
|
20
20
|
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
21
21
|
}
|
|
22
22
|
function determineSectionTitle(urlWithHash) {
|
|
23
|
-
assert(urlWithHash.includes('#'), { urlWithHash });
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
assert(urlWithHash.includes('#'), { urlWithHash: urlWithHash });
|
|
24
|
+
var urlHash = urlWithHash.split('#')[1];
|
|
25
|
+
var title = urlHash
|
|
26
26
|
.split('-')
|
|
27
|
-
.map((word, i)
|
|
27
|
+
.map(function (word, i) {
|
|
28
28
|
if (i === 0) {
|
|
29
29
|
return capitalizeFirstLetter(word);
|
|
30
30
|
}
|
package/dist/utils/filter.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { filter };
|
|
2
2
|
// https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
|
|
3
3
|
function filter(obj, predicate) {
|
|
4
|
-
|
|
5
|
-
Object.keys(obj).forEach((name)
|
|
4
|
+
var result = {};
|
|
5
|
+
Object.keys(obj).forEach(function (name) {
|
|
6
6
|
if (predicate(obj[name], name)) {
|
|
7
7
|
result[name] = obj[name];
|
|
8
8
|
}
|
|
@@ -2,8 +2,8 @@ export function getGlobalObject(
|
|
|
2
2
|
// We use the filename as key; each `getGlobalObject()` call should live inside a file with a unique filename.
|
|
3
3
|
key, defaultValue) {
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var globalObjectsAll = (globalThis[projectKey] = globalThis[projectKey] || {});
|
|
6
|
+
var globalObject = (globalObjectsAll[key] = globalObjectsAll[key] || defaultValue);
|
|
7
7
|
return globalObject;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
var projectKey = '_docpress';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export { useSelectedLanguage };
|
|
2
2
|
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var key = 'docpress:selectedLang';
|
|
4
|
+
var defaultSsrLang = 'ts';
|
|
5
|
+
var defaultClientLang = 'js';
|
|
6
6
|
function useSelectedLanguage() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var _a = useState(defaultSsrLang), selectedLang = _a[0], setSelectedLang = _a[1];
|
|
8
|
+
var getValue = function () {
|
|
9
|
+
var _a;
|
|
9
10
|
try {
|
|
10
|
-
return localStorage.getItem(key)
|
|
11
|
+
return (_a = localStorage.getItem(key)) !== null && _a !== void 0 ? _a : defaultClientLang;
|
|
11
12
|
}
|
|
12
13
|
catch (error) {
|
|
13
14
|
console.warn('Error reading from localStorage:', error);
|
|
14
15
|
return defaultClientLang;
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
+
var setValue = useCallback(function (value) {
|
|
18
19
|
try {
|
|
19
20
|
window.localStorage.setItem(key, value);
|
|
20
21
|
setSelectedLang(value);
|
|
@@ -24,22 +25,22 @@ function useSelectedLanguage() {
|
|
|
24
25
|
console.warn('Error setting localStorage:', error);
|
|
25
26
|
}
|
|
26
27
|
}, []);
|
|
27
|
-
useEffect(()
|
|
28
|
+
useEffect(function () {
|
|
28
29
|
// Initial load from localStorage
|
|
29
30
|
setSelectedLang(getValue());
|
|
30
31
|
// Update language in current tab
|
|
31
|
-
|
|
32
|
+
var handleCustomEvent = function () {
|
|
32
33
|
setSelectedLang(getValue());
|
|
33
34
|
};
|
|
34
35
|
// Update language if changed in another tab
|
|
35
|
-
|
|
36
|
+
var handleNativeStorage = function (event) {
|
|
36
37
|
if (event.key === key) {
|
|
37
38
|
setSelectedLang(getValue());
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
window.addEventListener('lang-storage', handleCustomEvent);
|
|
41
42
|
window.addEventListener('storage', handleNativeStorage);
|
|
42
|
-
return ()
|
|
43
|
+
return function () {
|
|
43
44
|
window.removeEventListener('lang-storage', handleCustomEvent);
|
|
44
45
|
window.removeEventListener('storage', handleNativeStorage);
|
|
45
46
|
};
|
package/dist/vite.config.js
CHANGED
|
@@ -6,16 +6,16 @@ import { detypePlugin } from './detypePlugin.js';
|
|
|
6
6
|
import rehypePrettyCode from 'rehype-pretty-code';
|
|
7
7
|
import remarkGfm from 'remark-gfm';
|
|
8
8
|
import { transformerNotationDiff } from '@shikijs/transformers';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
root,
|
|
9
|
+
var root = process.cwd();
|
|
10
|
+
var prettyCode = [rehypePrettyCode, { theme: 'github-light', transformers: [transformerNotationDiff()] }];
|
|
11
|
+
var rehypePlugins = [prettyCode];
|
|
12
|
+
var remarkPlugins = [remarkGfm];
|
|
13
|
+
var config = {
|
|
14
|
+
root: root,
|
|
15
15
|
plugins: [
|
|
16
16
|
parsePageSections(),
|
|
17
17
|
detypePlugin(),
|
|
18
|
-
mdx({ rehypePlugins, remarkPlugins }),
|
|
18
|
+
mdx({ rehypePlugins: rehypePlugins, remarkPlugins: remarkPlugins }),
|
|
19
19
|
// @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
|
|
20
20
|
react(),
|
|
21
21
|
],
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/docpress",
|
|
3
|
-
"version": "0.15.10-commit-
|
|
3
|
+
"version": "0.15.10-commit-e9efbd3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@brillout/picocolors": "^1.0.10",
|
|
7
|
-
"detype": "^1.1.2",
|
|
8
7
|
"@docsearch/css": "3.9.0",
|
|
9
8
|
"@docsearch/react": "3.9.0",
|
|
10
9
|
"@mdx-js/mdx": "3.0.1",
|
|
@@ -12,6 +11,7 @@
|
|
|
12
11
|
"@mdx-js/rollup": "3.0.1",
|
|
13
12
|
"@shikijs/transformers": "1.2.0",
|
|
14
13
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
14
|
+
"detype": "^1.1.2",
|
|
15
15
|
"rehype-pretty-code": "0.13.0",
|
|
16
16
|
"remark-gfm": "4.0.0",
|
|
17
17
|
"shiki": "1.2.0",
|