48 lines
1.1 KiB
Text
48 lines
1.1 KiB
Text
---
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
import Link from './Link.astro';
|
|
import Accordion from "@components/Accordion.astro"
|
|
|
|
interface Props {
|
|
title: string;
|
|
link: string;
|
|
current?: boolean;
|
|
}
|
|
interface VersionData {
|
|
default: string;
|
|
versions: {
|
|
name: string;
|
|
types: string;
|
|
}[]
|
|
}
|
|
const versionFilePath = import.meta.env.VERSION_FILE_PATH;
|
|
|
|
if (!versionFilePath){
|
|
throw new Error("no env var VERSION_FILE_PATH")
|
|
}
|
|
const absolutePath = path.resolve(process.cwd(), versionFilePath);
|
|
const versionData:VersionData = JSON.parse(fs.readFileSync(absolutePath, 'utf-8'));
|
|
|
|
const { title, link, current } = Astro.props;
|
|
---
|
|
<Accordion class=`nav-component version-collapsible ${current ? "nav-current" : ""}` {...(!current ? { open: "_" } : {})}>
|
|
<div slot="header">
|
|
<span class="nav-component nav-item nav-link">
|
|
versions
|
|
</span>
|
|
</div>
|
|
<div class="version-select-menu">
|
|
{versionData.versions.map((ver, _) => {
|
|
return (
|
|
<Link
|
|
link={`${Astro.url.pathname}`}
|
|
title=`${ver.name}`
|
|
>
|
|
{ver.name}
|
|
</Link>
|
|
)}
|
|
)}
|
|
</div>
|
|
</Accordion>
|