www: convert toc to .ts (#1381)
This commit is contained in:
+20
-11
@@ -1,6 +1,13 @@
|
||||
{
|
||||
type RawTableOfContents = Record<string, RawTableOfContentsEntry>;
|
||||
|
||||
interface RawTableOfContentsEntry {
|
||||
title: string;
|
||||
pages?: [string, string][];
|
||||
}
|
||||
|
||||
const toc: RawTableOfContents = {
|
||||
"introduction": {
|
||||
"title": "Introduction"
|
||||
"title": "Introduction",
|
||||
},
|
||||
"getting-started": {
|
||||
"title": "Getting Started",
|
||||
@@ -13,8 +20,8 @@
|
||||
["fetching-data", "Fetching data"],
|
||||
["form-submissions", "Form submissions"],
|
||||
["adding-interactivity", "Adding interactivity"],
|
||||
["deploy-to-production", "Deploy to production"]
|
||||
]
|
||||
["deploy-to-production", "Deploy to production"],
|
||||
],
|
||||
},
|
||||
"concepts": {
|
||||
"title": "Concepts",
|
||||
@@ -32,11 +39,11 @@
|
||||
["plugins", "Plugins"],
|
||||
["updating", "Updating Fresh"],
|
||||
["app-wrapper", "Application wrapper"],
|
||||
["server-configuration", "Server configuration"]
|
||||
]
|
||||
["server-configuration", "Server configuration"],
|
||||
],
|
||||
},
|
||||
"integrations": {
|
||||
"title": "Integrations"
|
||||
"title": "Integrations",
|
||||
},
|
||||
"examples": {
|
||||
"title": "Examples",
|
||||
@@ -52,7 +59,9 @@
|
||||
["creating-a-crud-api", "Creating a CRUD API"],
|
||||
["handling-complex-routes", "Handling complex routes"],
|
||||
["rendering-markdown", "Rendering markdown"],
|
||||
["sharing-state-between-islands", "Sharing state between islands"]
|
||||
]
|
||||
}
|
||||
}
|
||||
["sharing-state-between-islands", "Sharing state between islands"],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export default toc;
|
||||
+8
-12
@@ -1,11 +1,4 @@
|
||||
import RAW_TOC from "../../docs/toc.json" assert { type: "json" };
|
||||
|
||||
type RawTableOfContents = Record<string, RawTableOfContentsEntry>;
|
||||
|
||||
interface RawTableOfContentsEntry {
|
||||
title: string;
|
||||
pages?: [string, string][];
|
||||
}
|
||||
import toc from "../../docs/toc.ts";
|
||||
|
||||
export interface TableOfContentsEntry {
|
||||
slug: string;
|
||||
@@ -29,8 +22,8 @@ export interface TableOfContentsCategoryEntry {
|
||||
export const TABLE_OF_CONTENTS: Record<string, TableOfContentsEntry> = {};
|
||||
export const CATEGORIES: TableOfContentsCategory[] = [];
|
||||
|
||||
for (const parent in (RAW_TOC as unknown as RawTableOfContents)) {
|
||||
const rawEntry = (RAW_TOC as unknown as RawTableOfContents)[parent];
|
||||
for (const parent in toc) {
|
||||
const rawEntry = toc[parent];
|
||||
const href = `/docs/${parent}`;
|
||||
const file = `docs/${parent}/index.md`;
|
||||
const entry = {
|
||||
@@ -46,8 +39,11 @@ for (const parent in (RAW_TOC as unknown as RawTableOfContents)) {
|
||||
entries: [],
|
||||
};
|
||||
CATEGORIES.push(category);
|
||||
if (rawEntry.pages) {
|
||||
for (const [id, title] of rawEntry.pages) {
|
||||
const filteredPages = rawEntry.pages?.filter(([title, page]) =>
|
||||
title != null && page != null
|
||||
);
|
||||
if (filteredPages) {
|
||||
for (const [id, title] of filteredPages) {
|
||||
const slug = `${parent}/${id}`;
|
||||
const href = `/docs/${slug}`;
|
||||
const file = `docs/${slug}.md`;
|
||||
|
||||
Reference in New Issue
Block a user