squash and nuke dev

This commit is contained in:
outfoxxed 2026-02-18 02:40:40 -08:00
parent b2d43ad425
commit f26e76c114
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
93 changed files with 33827 additions and 7831 deletions

View file

@ -1,17 +1,22 @@
import { type CollectionEntry, getCollection } from "astro:content";
import {
type CollectionEntry,
getCollection,
} from "astro:content";
import { getVersionsData } from "@config/io/generateTypeData";
// load latest version of each page for version
async function buildGuideCollection(version: string): Promise<CollectionEntry<'guide'>[]> {
async function buildGuideCollection(
version: string
): Promise<CollectionEntry<"guide">[]> {
const { versions } = await getVersionsData();
const guidePages = await getCollection("guide");
const pages: { [key: string]: CollectionEntry<'guide'> } = {};
const pages: { [key: string]: CollectionEntry<"guide"> } = {};
for (const currentVersion of versions.toReversed()) {
for (const page of guidePages) {
let [guideVersion, id] = page.id.split('/');
guideVersion = guideVersion.replaceAll('_', '.');
let [guideVersion, id] = page.id.split("/");
guideVersion = guideVersion.replaceAll("_", ".");
id = id ?? "index";
if (guideVersion !== currentVersion.name) continue;
@ -24,12 +29,18 @@ async function buildGuideCollection(version: string): Promise<CollectionEntry<'g
return Object.values(pages);
}
let guideCollections: { [key: string]: Promise<CollectionEntry<'guide'>[]> } = {};
let guideCollections: {
[key: string]: Promise<CollectionEntry<"guide">[]>;
} = {};
export async function getGuideCollection(version: string): Promise<CollectionEntry<'guide'>[]> {
async function getGuideCollection(
version: string
): Promise<CollectionEntry<"guide">[]> {
if (!(version in guideCollections)) {
guideCollections[version] = buildGuideCollection(version);
}
return guideCollections[version];
}
export { getGuideCollection };