added changelog and version dropdown
This commit is contained in:
parent
9af300bb35
commit
d1e1d3c529
9 changed files with 134 additions and 27 deletions
48
src/components/navigation/sidebars/nav/VersionSelector.astro
Normal file
48
src/components/navigation/sidebars/nav/VersionSelector.astro
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue