version docs pages

This commit is contained in:
outfoxxed 2025-07-22 01:08:30 -07:00
parent 5865251560
commit 9828872a3c
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
28 changed files with 321 additions and 327 deletions

View file

@ -2,7 +2,6 @@
import "@pagefind/default-ui/css/ui.css";
import magnifierIcon from "@icons/magnifier.svg?raw"
---
<site-search class="search-wrapper">
<button
data-open-modal
@ -52,7 +51,6 @@ import magnifierIcon from "@icons/magnifier.svg?raw"
<script>
import { getQMLTypeLinkObject, getQMLTypeLink, getIconForLink } from '@src/config/io/helpers';
class SiteSearch extends HTMLElement {
constructor() {
super();
@ -107,7 +105,7 @@ import { getQMLTypeLinkObject, getQMLTypeLink, getIconForLink } from '@src/confi
if (match.length > 0){
for (const matching of match) {
const linkObject = getQMLTypeLinkObject(matching[1]);
const link = getQMLTypeLink(linkObject);
const link = getQMLTypeLink("NOVERSION", linkObject);
const icon = linkObject.mtype ? getIconForLink(linkObject.mtype, false) : null;
// for signal

View file

@ -5,15 +5,18 @@ export interface Props {
currentClass?: string;
}
import { getModulesData } from "@config/io/generateTypeData";
import { getVersionsData } from "@config/io/generateTypeData";
import type { TreeEntry } from "./Tree.astro";
import Tree from "./Tree.astro";
import Link from "./Link.astro";
import VersionSelector from "./VersionSelector.astro"
const modules = await getModulesData();
import { getCollection } from "astro:content";
const versions = await getVersionsData();
const versionName = Astro.params.version;
const modules = versions.versions.find(version => version.name === versionName)?.modules;
const currentPath = Astro.url.pathname.split('/').filter(s => s !== "");
const guidePages = await getCollection("guide");
interface NavTree {
@ -22,8 +25,6 @@ interface NavTree {
entries?: NavTree[],
}
const currentPath = Astro.url.pathname.slice(1).split('/');
function mkTree(mount: string, pathIdx: number, { title, slug, entries }: NavTree): TreeEntry {
const link = `${mount}/${slug}`;
@ -48,43 +49,67 @@ function genGuideNav(base: string): NavTree[] | undefined {
return pages.length === 0 ? undefined : pages;
}
const guide = mkTree("/docs", 1, {
title: "Usage Guide",
slug: "guide",
entries: genGuideNav(""),
});
let versionedEntries;
let versionsTree;
const types = mkTree("/docs", 1, {
title: "Quickshell Types",
slug: "types",
entries: modules.map(module => ({
title: module.name,
slug: module.name,
entries: module.types.map(type => ({
title: type.name,
slug: type.name,
}))
}))
});
if (versionName) {
versionedEntries = {
guide: mkTree(`/docs/${versionName}`, 2, {
title: "Usage Guide",
slug: "guide",
entries: genGuideNav(""),
}),
types: mkTree(`/docs/${versionName}`, 2, {
title: "Quickshell Types",
slug: "types",
entries: modules!.map(module => ({
title: module.name,
slug: module.name,
entries: module.types.map(type => ({
title: type.name,
slug: type.name,
}))
}))
}),
};
versionsTree = {
title: `Switch Version (${versionName})`,
link: "#",
entries: versions.versions.map(version => ({
title: version.name,
link: `/docs/${version.name}${Astro.url.pathname.slice(6 + versionName.length)}`,
current: version.name == versionName,
})),
};
}
---
<nav class="navtree">
<VersionSelector title="Versions" link=`${Astro.currentLocale}` current/>
<Link
title="About Quickshell"
title="About"
link="/about"
current={Astro.url.pathname === "/about"}
/>
<Tree {...guide}/>
<Tree {...types}/>
<Link
title="QtQuick Types"
link="https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
showIcon={true}
/>
<Link
title="Quickshell Examples"
link="https://git.outfoxxed.me/outfoxxed/quickshell-examples"
showIcon={true}
current={currentPath.length === 1 && currentPath[0] === "about"}
/>
{ versionedEntries && <Tree {...versionsTree as TreeEntry}/>}
<hr/>
{ versionedEntries && (
<Tree {...versionedEntries.guide}/>
<Tree {...versionedEntries.types}/>
<Link
title="QtQuick Types"
link="https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
showIcon={true}
/>
<Link
title="Quickshell Examples"
link="https://git.outfoxxed.me/outfoxxed/quickshell-examples"
showIcon={true}
/>
)}
{ !versionedEntries && versions.versions.map(version => (
<Link
title={`Quickshell Documentation (${version.name})`}
link={`/docs/${version.name}/guide`}
/>
))}
</nav>

View file

@ -1,48 +0,0 @@
---
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>