Skip to content

Commit 02f3f9f

Browse files
authored
feat(components/version): allow to remove version prefix
1 parent 8c9035f commit 02f3f9f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/components/Code.astro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface Props extends ExpressiveCodeBlockProps
66
{
77
code: string;
88
lang: string;
9+
noVersion?: boolean;
910
}
1011
1112
const response = await fetch(
@@ -19,9 +20,15 @@ const response = await fetch(
1920
);
2021
2122
const parsed = await response.json();
22-
const version = parsed?.[0]?.["name"] ?? "v8.0.0";
23+
let version = parsed?.[0]?.["name"] ?? "v8.0.0";
24+
25+
const { code, lang, noVersion, ...props } = Astro.props;
26+
27+
if (noVersion)
28+
{
29+
version = version.substring(1);
30+
}
2331
24-
const { code, lang, ...props } = Astro.props;
2532
const versionedCode = code.replace("$VERSION$", version);
2633
---
2734

0 commit comments

Comments
 (0)