Skip to content

Commit

Permalink
chore(docs): use Vite define instead of import
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Dec 30, 2023
1 parent acde609 commit 8881de2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import svelte from "@astrojs/svelte";
import { defineConfig } from "astro/config";
import { version } from "../package.json" assert { type: "json" };

export default defineConfig({
integrations: [svelte()],
vite: {
define: {
__VERSION: JSON.stringify(version),
},
},
});
4 changes: 2 additions & 2 deletions docs/src/components/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
SkipToContent,
} from "carbon-components-svelte";
import LogoGithub from "./LogoGithub.svelte";
import { version } from "../../../package.json";
import { VERSION } from "../constants";
</script>

<Header aria-label="Navigation" href="/">
Expand All @@ -20,7 +20,7 @@

<span slot="platform" class="platform-name">
Carbon Pictograms Svelte
<code title="Version {version}">v{version}</code>
<code title="Version {VERSION}">v{VERSION}</code>
</span>

<HeaderUtilities>
Expand Down
3 changes: 1 addition & 2 deletions docs/src/components/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import fuzzy from "fuzzy";
import Header from "./Header.svelte";
import * as pictograms from "../../../lib";
import { version } from "../../../package.json";
const { match } = fuzzy;
const pictogramNames = Object.keys(pictograms);
Expand All @@ -34,7 +33,7 @@

<FocusKey element={ref} selectText />

<Header {version} />
<Header />

<Modal
passiveModal
Expand Down
1 change: 1 addition & 0 deletions docs/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = __VERSION;
2 changes: 2 additions & 0 deletions docs/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference types="astro/client" />

declare const __VERSION: string;

0 comments on commit 8881de2

Please sign in to comment.