Skip to content

Commit a637639

Browse files
Merge pull request #27 from geoadmin/PB-1887-build-issues
PB-1887: adress warnings after build script
2 parents c5dac4b + c1e855f commit a637639

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

.vitepress/config.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export default defineConfig({
77
description: "Technical Documentation about *.geo.admin.ch",
88
head: [["link", { rel: "icon", href: "/static/favicon.ico" }]],
99
ignoreDeadLinks: "localhostLinks",
10+
vite: {
11+
build: {
12+
// We add this to avoid the warning "(!) Some chunks are larger than 500 kB after minification."
13+
chunkSizeWarningLimit: 1000,
14+
},
15+
},
1016
themeConfig: {
1117
// https://vitepress.dev/reference/default-theme-config
1218

.vitepress/theme/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@ import ExampleCodeBlock from "../../components/ExampleCodeBlock.vue";
66
import { createHighlighter } from "shiki";
77
import type { HighlighterGeneric, BundledLanguage, BundledTheme } from "shiki";
88

9+
// Create a global instance of the highlighter as Shiki is supposed to be used as a singleton
10+
const highlighterPromise = createHighlighter({
11+
themes: ["github-dark"],
12+
langs: ["javascript", "json", "sh", "html", "http"],
13+
});
14+
915
export default {
1016
extends: DefaultTheme,
1117
async enhanceApp({ app }) {
12-
// register your custom global components
18+
// register custom global components
1319
app.component("ApiCodeBlock", ApiCodeBlock);
1420
app.component("ExampleCodeBlock", ExampleCodeBlock);
1521

16-
// Initialize the highlighter asynchronously
1722
const highlighter: HighlighterGeneric<BundledLanguage, BundledTheme> =
18-
await createHighlighter({
19-
themes: ["github-dark"],
20-
langs: ["javascript", "json", "sh", "html", "http"],
21-
});
23+
await highlighterPromise;
2224

23-
// Provide the highlighter globally
25+
// Provide the highlighter globally (it can later be used in any component)
2426
app.provide("highlighter", highlighter);
2527
},
2628
} satisfies Theme;

components/ApiCodeBlock.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
method?: string;
1212
}>();
1313
14-
const highlighter:
15-
| HighlighterGeneric<BundledLanguage, BundledTheme>
16-
| undefined = inject("highlighter");
14+
const highlighter =
15+
inject<HighlighterGeneric<BundledLanguage, BundledTheme>>("highlighter");
1716
1817
const html = highlighter?.codeToHtml(props.url, {
1918
lang: "http",

0 commit comments

Comments
 (0)