@vited/theme-mantine 0.1.0 → 0.2.1
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/CHANGELOG.md +6 -0
- package/dist/index.mjs +41 -43
- package/package.json +16 -14
package/CHANGELOG.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -34,11 +34,7 @@ themeI18n.use(initReactI18next).init({
|
|
|
34
34
|
github: "GitHub",
|
|
35
35
|
donate: "Donate",
|
|
36
36
|
copy: "Copy",
|
|
37
|
-
copied: "Copied"
|
|
38
|
-
locales: {
|
|
39
|
-
en: "English",
|
|
40
|
-
zh: "简体中文"
|
|
41
|
-
}
|
|
37
|
+
copied: "Copied"
|
|
42
38
|
} },
|
|
43
39
|
zh: { translation: {
|
|
44
40
|
language: "语言",
|
|
@@ -54,11 +50,7 @@ themeI18n.use(initReactI18next).init({
|
|
|
54
50
|
github: "GitHub",
|
|
55
51
|
donate: "赞助",
|
|
56
52
|
copy: "复制",
|
|
57
|
-
copied: "已复制"
|
|
58
|
-
locales: {
|
|
59
|
-
en: "English",
|
|
60
|
-
zh: "简体中文"
|
|
61
|
-
}
|
|
53
|
+
copied: "已复制"
|
|
62
54
|
} }
|
|
63
55
|
},
|
|
64
56
|
interpolation: { escapeValue: false },
|
|
@@ -72,7 +64,9 @@ function getProjectLinks(packageJSON = {}) {
|
|
|
72
64
|
};
|
|
73
65
|
}
|
|
74
66
|
function getGitHubRepositoryUrl(repository) {
|
|
75
|
-
|
|
67
|
+
let repositoryUrl;
|
|
68
|
+
if (typeof repository === "string") repositoryUrl = repository;
|
|
69
|
+
else if (isRecord(repository) && typeof repository.url === "string") repositoryUrl = repository.url;
|
|
76
70
|
if (!repositoryUrl) return void 0;
|
|
77
71
|
let normalized = repositoryUrl.trim().replace(/^git\+/, "");
|
|
78
72
|
const shorthand = normalized.match(/^github:([^/]+\/[^/]+)$/i);
|
|
@@ -80,7 +74,7 @@ function getGitHubRepositoryUrl(repository) {
|
|
|
80
74
|
const ssh = normalized.match(/^(?:git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+\/[^/]+)$/i);
|
|
81
75
|
if (ssh) normalized = `https://github.com/${ssh[1]}`;
|
|
82
76
|
try {
|
|
83
|
-
const url = new URL(normalized);
|
|
77
|
+
const url = new globalThis.URL(normalized);
|
|
84
78
|
if (url.protocol !== "https:" && url.protocol !== "http:") return void 0;
|
|
85
79
|
if (url.hostname.toLowerCase() !== "github.com") return void 0;
|
|
86
80
|
const [owner, repositoryName] = url.pathname.split("/").filter(Boolean);
|
|
@@ -98,10 +92,12 @@ function getFundingUrl(funding) {
|
|
|
98
92
|
}
|
|
99
93
|
return;
|
|
100
94
|
}
|
|
101
|
-
|
|
95
|
+
let value;
|
|
96
|
+
if (typeof funding === "string") value = funding;
|
|
97
|
+
else if (isRecord(funding) && typeof funding.url === "string") value = funding.url;
|
|
102
98
|
if (!value) return void 0;
|
|
103
99
|
try {
|
|
104
|
-
const url = new URL(value);
|
|
100
|
+
const url = new globalThis.URL(value);
|
|
105
101
|
return url.protocol === "https:" || url.protocol === "http:" ? url.href : void 0;
|
|
106
102
|
} catch {
|
|
107
103
|
return;
|
|
@@ -147,7 +143,7 @@ function removeBase(pathname, base) {
|
|
|
147
143
|
function createPageSearch(documents) {
|
|
148
144
|
const indexedDocuments = documents.map((document) => ({
|
|
149
145
|
document,
|
|
150
|
-
cjkContent: `${document.title}${document.content}`.
|
|
146
|
+
cjkContent: `${document.title}${document.content}`.replaceAll(/[^\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu, "")
|
|
151
147
|
}));
|
|
152
148
|
const fuse = new Fuse(indexedDocuments, {
|
|
153
149
|
keys: [
|
|
@@ -195,13 +191,14 @@ const codeHighlightAdapter = createShikiAdapter(() => createHighlighter({
|
|
|
195
191
|
]
|
|
196
192
|
}), { resolveLanguage: (language) => {
|
|
197
193
|
const normalizedLanguage = language.toLowerCase();
|
|
198
|
-
return normalizedLanguage in bundledLanguages ? bundledLanguages[normalizedLanguage] :
|
|
194
|
+
return normalizedLanguage in bundledLanguages ? bundledLanguages[normalizedLanguage] : void 0;
|
|
199
195
|
} });
|
|
196
|
+
const emptyLocales = [];
|
|
200
197
|
function findPage(pages, pathname, locale) {
|
|
201
198
|
return pages.find((page) => page.path === pathname && page.locale === locale) ?? pages.find((page) => page.path === pathname) ?? pages[0];
|
|
202
199
|
}
|
|
203
|
-
function ThemeApp({ pages, title = "", description = "", supportedLocales =
|
|
204
|
-
const locales = supportedLocales.length > 0 ? supportedLocales : [...new Set(pages.map((item) => item.locale))];
|
|
200
|
+
function ThemeApp({ pages, title = "", description = "", supportedLocales = emptyLocales, menu, searchIndex = [], packageJSON = {} }) {
|
|
201
|
+
const locales = useMemo(() => supportedLocales.length > 0 ? supportedLocales : [...new Set(pages.map((item) => item.locale))], [pages, supportedLocales]);
|
|
205
202
|
const [pathname, navigate] = useLocation();
|
|
206
203
|
const route = resolveLocalizedRoute(pathname, locales);
|
|
207
204
|
const locale = route.locale;
|
|
@@ -248,13 +245,13 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
248
245
|
onNavigate: () => setMobileOpened(false)
|
|
249
246
|
});
|
|
250
247
|
useEffect(() => {
|
|
251
|
-
document.documentElement.lang = locale;
|
|
248
|
+
globalThis.document.documentElement.lang = locale;
|
|
252
249
|
i18n.changeLanguage(locale);
|
|
253
250
|
}, [i18n, locale]);
|
|
254
251
|
function changeLocale(nextLocale) {
|
|
255
252
|
if (!nextLocale) return;
|
|
256
253
|
const localizedPath = makeLocalizedPath("/", route.pathname, nextLocale, locales);
|
|
257
|
-
const url = new URL(
|
|
254
|
+
const url = new globalThis.URL(globalThis.location.href);
|
|
258
255
|
url.searchParams.delete("lang");
|
|
259
256
|
navigate(`${localizedPath}${url.search}${url.hash}`);
|
|
260
257
|
}
|
|
@@ -294,7 +291,7 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
294
291
|
lineClamp: 1,
|
|
295
292
|
visibleFrom: "sm",
|
|
296
293
|
children: description
|
|
297
|
-
}) :
|
|
294
|
+
}) : void 0]
|
|
298
295
|
})]
|
|
299
296
|
}), /* @__PURE__ */ jsxs(Group, {
|
|
300
297
|
gap: "xs",
|
|
@@ -321,7 +318,7 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
321
318
|
size: "sm",
|
|
322
319
|
children: t("search")
|
|
323
320
|
})
|
|
324
|
-
}) :
|
|
321
|
+
}) : void 0,
|
|
325
322
|
projectLinks.github ? /* @__PURE__ */ jsx(Tooltip, {
|
|
326
323
|
label: t("github"),
|
|
327
324
|
withArrow: true,
|
|
@@ -335,7 +332,7 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
335
332
|
"aria-label": t("github"),
|
|
336
333
|
children: /* @__PURE__ */ jsx(GithubLogo, { size: 20 })
|
|
337
334
|
})
|
|
338
|
-
}) :
|
|
335
|
+
}) : void 0,
|
|
339
336
|
projectLinks.funding ? /* @__PURE__ */ jsx(Tooltip, {
|
|
340
337
|
label: t("donate"),
|
|
341
338
|
withArrow: true,
|
|
@@ -352,19 +349,19 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
352
349
|
color: "red"
|
|
353
350
|
})
|
|
354
351
|
})
|
|
355
|
-
}) :
|
|
352
|
+
}) : void 0,
|
|
356
353
|
locales.length > 1 ? /* @__PURE__ */ jsx(Select, {
|
|
357
354
|
"aria-label": t("language"),
|
|
358
355
|
data: locales.map((item) => ({
|
|
359
356
|
value: item,
|
|
360
|
-
label:
|
|
357
|
+
label: new Intl.DisplayNames([item], { type: "language" }).of(item) ?? item
|
|
361
358
|
})),
|
|
362
359
|
value: locale,
|
|
363
360
|
onChange: changeLocale,
|
|
364
361
|
allowDeselect: false,
|
|
365
362
|
w: 120,
|
|
366
363
|
size: "sm"
|
|
367
|
-
}) :
|
|
364
|
+
}) : void 0,
|
|
368
365
|
/* @__PURE__ */ jsx(ActionIcon, {
|
|
369
366
|
variant: "default",
|
|
370
367
|
size: "lg",
|
|
@@ -424,7 +421,7 @@ function ThemeApp({ pages, title = "", description = "", supportedLocales = [],
|
|
|
424
421
|
shortcut: "mod + K",
|
|
425
422
|
highlightQuery: true,
|
|
426
423
|
limit: 8
|
|
427
|
-
}) :
|
|
424
|
+
}) : void 0
|
|
428
425
|
]
|
|
429
426
|
});
|
|
430
427
|
}
|
|
@@ -448,7 +445,7 @@ function PageNavigation({ pages, locales, activePath, locale, onNavigate }) {
|
|
|
448
445
|
const nodes = [];
|
|
449
446
|
for (const page of pages) {
|
|
450
447
|
let level = nodes;
|
|
451
|
-
const segments = page.path.split("/").filter(Boolean).map(decodeURIComponent);
|
|
448
|
+
const segments = page.path.split("/").filter(Boolean).map((segment) => decodeURIComponent(segment));
|
|
452
449
|
if (segments.length === 0) {
|
|
453
450
|
level.push({
|
|
454
451
|
key: `${page.locale}:${page.path}`,
|
|
@@ -491,7 +488,7 @@ function renderPageNavigationNodes(nodes, props) {
|
|
|
491
488
|
active: node.page?.path === props.activePath,
|
|
492
489
|
defaultOpened: node.children.some((child) => child.page?.path === props.activePath || props.activePath?.startsWith(`${child.key}/`)),
|
|
493
490
|
component: node.page ? "a" : "button",
|
|
494
|
-
children: node.children.length > 0 ? renderPageNavigationNodes(node.children, props) :
|
|
491
|
+
children: node.children.length > 0 ? renderPageNavigationNodes(node.children, props) : void 0
|
|
495
492
|
});
|
|
496
493
|
return node.page ? /* @__PURE__ */ jsx(Link, {
|
|
497
494
|
to: makeLocalizedPath("/", node.page.path, props.locale, props.locales),
|
|
@@ -519,7 +516,7 @@ function MenuItems({ entries, locales, locale, activePath, onNavigate }) {
|
|
|
519
516
|
locale,
|
|
520
517
|
activePath,
|
|
521
518
|
onNavigate
|
|
522
|
-
}) :
|
|
519
|
+
}) : void 0
|
|
523
520
|
});
|
|
524
521
|
return entry.path ? /* @__PURE__ */ jsx(Link, {
|
|
525
522
|
to: href,
|
|
@@ -547,22 +544,23 @@ function getLocalizedPages(pages, locales) {
|
|
|
547
544
|
return routes;
|
|
548
545
|
}
|
|
549
546
|
function getSearchShortcut() {
|
|
550
|
-
return
|
|
547
|
+
return globalThis.navigator !== void 0 && /Mac|iPhone|iPad|iPod/.test(globalThis.navigator.platform) ? "⌘ K" : "Ctrl + K";
|
|
551
548
|
}
|
|
552
549
|
function humanize(value) {
|
|
553
|
-
return decodeURIComponent(value).
|
|
550
|
+
return decodeURIComponent(value).replaceAll(/[-_]/g, " ");
|
|
554
551
|
}
|
|
555
552
|
function MarkdownHtml({ html = "" }) {
|
|
556
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: parse(html, { replace
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
553
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: parse(html, { replace: replaceMarkdownHtmlNode }) });
|
|
554
|
+
}
|
|
555
|
+
function replaceMarkdownHtmlNode(node) {
|
|
556
|
+
if (!(node instanceof Element) || node.name !== "pre") return;
|
|
557
|
+
const codeNode = node.children.find((child) => child instanceof Element && child.name === "code");
|
|
558
|
+
if (!codeNode) return;
|
|
559
|
+
const code = codeNode.children.map(getHtmlText).join("");
|
|
560
|
+
return /* @__PURE__ */ jsx(MarkdownCodeBlock, { children: /* @__PURE__ */ jsx("code", {
|
|
561
|
+
className: codeNode.attribs.class,
|
|
562
|
+
children: code
|
|
563
|
+
}) });
|
|
566
564
|
}
|
|
567
565
|
function MarkdownCodeBlock({ children }) {
|
|
568
566
|
const { t } = useTranslation();
|
|
@@ -587,7 +585,7 @@ function getHtmlText(node) {
|
|
|
587
585
|
}
|
|
588
586
|
function getReactText(node) {
|
|
589
587
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
590
|
-
if (Array.isArray(node)) return node.map(getReactText).join("");
|
|
588
|
+
if (Array.isArray(node)) return node.map((child) => getReactText(child)).join("");
|
|
591
589
|
if (isValidElement(node)) return getReactText(node.props.children);
|
|
592
590
|
return "";
|
|
593
591
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vited/theme-mantine",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Mantine React theme for Vited documentation sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"documentation",
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
"license": "MPL-2.0",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Guo Yunhe",
|
|
19
|
-
"email": "i@guoyunhe.me"
|
|
19
|
+
"email": "i@guoyunhe.me",
|
|
20
|
+
"url": "https://guoyunhe.me/"
|
|
20
21
|
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
23
24
|
"url": "git+https://github.com/vitedjs/theme-mantine.git"
|
|
24
25
|
},
|
|
26
|
+
"funding": "https://ko-fi.com/guoyunhe",
|
|
25
27
|
"files": [
|
|
26
28
|
"dist",
|
|
27
29
|
"CHANGELOG.md",
|
|
@@ -38,8 +40,8 @@
|
|
|
38
40
|
}
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@mantine/core": "^9.7.4",
|
|
42
43
|
"@mantine/code-highlight": "^9.7.4",
|
|
44
|
+
"@mantine/core": "^9.7.4",
|
|
43
45
|
"@mantine/spotlight": "^9.7.4",
|
|
44
46
|
"@phosphor-icons/react": "^2.1.10",
|
|
45
47
|
"fuse.js": "^7.5.0",
|
|
@@ -53,25 +55,25 @@
|
|
|
53
55
|
"@guoyunhe/editorconfig": "^0.3.0",
|
|
54
56
|
"@guoyunhe/oxfmt-config": "^1.1.0",
|
|
55
57
|
"@mantine/core": "^9.7.4",
|
|
56
|
-
"@types/node": "^22.
|
|
57
|
-
"@types/react": "^19.
|
|
58
|
+
"@types/node": "^22.20.5",
|
|
59
|
+
"@types/react": "^19.3.0",
|
|
58
60
|
"@vited/cli": "link:../cli",
|
|
59
61
|
"@vited/core": "link:../core",
|
|
60
62
|
"husky": "^9.1.7",
|
|
61
63
|
"lint-staged": "^17.6.0",
|
|
62
64
|
"oxfmt": "^0.74.0",
|
|
63
|
-
"oxlint": "^1.
|
|
64
|
-
"oxlint-config-recommended": "^1.1
|
|
65
|
+
"oxlint": "^1.90.0",
|
|
66
|
+
"oxlint-config-recommended": "^1.2.1",
|
|
65
67
|
"react": "^19.3.1",
|
|
66
68
|
"stylelint": "^17.16.0",
|
|
67
69
|
"stylelint-config-standard": "^40.0.0",
|
|
68
|
-
"tsdown": "^0.23.
|
|
69
|
-
"typescript": "^5.
|
|
70
|
+
"tsdown": "^0.23.3",
|
|
71
|
+
"typescript": "^5.9.3",
|
|
70
72
|
"vitest": "^5.0.5"
|
|
71
73
|
},
|
|
72
74
|
"peerDependencies": {
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
+
"@vited/core": "^0.1.0",
|
|
76
|
+
"react": "^19.2.0"
|
|
75
77
|
},
|
|
76
78
|
"lint-staged": {
|
|
77
79
|
"*.{js,mjs,cjs,ts,mts,cts,jsx,tsx,vue}": [
|
|
@@ -87,18 +89,18 @@
|
|
|
87
89
|
"devEngines": {
|
|
88
90
|
"packageManager": {
|
|
89
91
|
"name": "pnpm",
|
|
90
|
-
"version": ">=12.
|
|
92
|
+
"version": ">=12.16.1",
|
|
91
93
|
"onFail": "error"
|
|
92
94
|
}
|
|
93
95
|
},
|
|
94
96
|
"engines": {
|
|
95
|
-
"node": "^
|
|
97
|
+
"node": "^22.0.0 || ^24.0.0 || ^26.0.0 || >=27.0.0"
|
|
96
98
|
},
|
|
97
99
|
"scripts": {
|
|
98
100
|
"build": "tsdown",
|
|
99
101
|
"format": "oxfmt --write .",
|
|
100
102
|
"format:check": "oxfmt --check .",
|
|
101
|
-
"lint": "oxlint && stylelint \"**/*.css\"",
|
|
103
|
+
"lint": "oxlint && stylelint --allow-empty-input \"**/*.css\"",
|
|
102
104
|
"test": "vitest run",
|
|
103
105
|
"test:watch": "vitest"
|
|
104
106
|
}
|