only generate type data once
This commit is contained in:
parent
8fb1408bb4
commit
e0a2fb0256
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
import { ThemeSelect } from "@components/hooks/ThemeSwitch";
|
import { ThemeSelect } from "@components/hooks/ThemeSwitch";
|
||||||
import { generateTypeData } from "@config/io/generateTypeData";
|
import { getTypeData } from "@config/io/generateTypeData";
|
||||||
import Nav from "@components/navigation/sidebars/Nav.astro";
|
import Nav from "@components/navigation/sidebars/Nav.astro";
|
||||||
import TOC from "@components/navigation/sidebars/TOC.astro";
|
import TOC from "@components/navigation/sidebars/TOC.astro";
|
||||||
import type { TypeTOC } from "./navigation/sidebars/types";
|
import type { TypeTOC } from "./navigation/sidebars/types";
|
||||||
import Search from "./navigation/Search.astro";
|
import Search from "./navigation/Search.astro";
|
||||||
|
|
||||||
const routes = await generateTypeData();
|
const routes = await getTypeData();
|
||||||
|
|
||||||
const url = Astro.url.pathname.split("/");
|
const url = Astro.url.pathname.split("/");
|
||||||
const currentClass = url[4];
|
const currentClass = url[4];
|
||||||
|
|
|
@ -7,11 +7,11 @@ export interface Props {
|
||||||
|
|
||||||
const { currentRoute, currentModule, currentClass } = Astro.props;
|
const { currentRoute, currentModule, currentClass } = Astro.props;
|
||||||
|
|
||||||
import { generateTypeData } from "@config/io/generateTypeData";
|
import { getTypeData } from "@config/io/generateTypeData";
|
||||||
import { groupRoutes } from "@config/io/helpers";
|
import { groupRoutes } from "@config/io/helpers";
|
||||||
import Tree from "./Tree.astro";
|
import Tree from "./Tree.astro";
|
||||||
|
|
||||||
const routes = await generateTypeData();
|
const routes = await getTypeData();
|
||||||
const groupedRoutes = groupRoutes(routes);
|
const groupedRoutes = groupRoutes(routes);
|
||||||
|
|
||||||
const configuration = {
|
const configuration = {
|
||||||
|
|
|
@ -30,7 +30,7 @@ async function readSubdir(subdir: string): Promise<dirData[]> {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateTypeData(): Promise<RouteData[]> {
|
async function generateTypeData(): Promise<RouteData[]> {
|
||||||
const mainDir = import.meta.env.SECRET_MODULES_PATH;
|
const mainDir = import.meta.env.SECRET_MODULES_PATH;
|
||||||
|
|
||||||
if (!mainDir || mainDir == "") {
|
if (!mainDir || mainDir == "") {
|
||||||
|
@ -56,3 +56,13 @@ export async function generateTypeData(): Promise<RouteData[]> {
|
||||||
}
|
}
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let globalTypeData: Promise<RouteData[]>;
|
||||||
|
|
||||||
|
export function getTypeData(): Promise<RouteData[]> {
|
||||||
|
if (!globalTypeData) {
|
||||||
|
globalTypeData = generateTypeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
return globalTypeData;
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
import { getQMLTypeLink } from "@config/io/helpers";
|
import { getQMLTypeLink } from "@config/io/helpers";
|
||||||
import { processMarkdown } from "@config/io/markdown";
|
import { processMarkdown } from "@config/io/markdown";
|
||||||
import { generateTypeData } from "@config/io/generateTypeData";
|
import { getTypeData } from "@config/io/generateTypeData";
|
||||||
import DocsLayout from "@layouts/DocsLayout.astro";
|
import DocsLayout from "@layouts/DocsLayout.astro";
|
||||||
import TOC from "@components/navigation/sidebars/TOC.astro";
|
import TOC from "@components/navigation/sidebars/TOC.astro";
|
||||||
import Properties from "@components/type/Properties.astro";
|
import Properties from "@components/type/Properties.astro";
|
||||||
|
@ -11,7 +11,7 @@ import Variants from "@components/type/Variants.astro";
|
||||||
import Badge from "@components/Badge.astro";
|
import Badge from "@components/Badge.astro";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const routes = await generateTypeData();
|
const routes = await getTypeData();
|
||||||
|
|
||||||
return routes
|
return routes
|
||||||
.filter(route => route.name !== "index")
|
.filter(route => route.name !== "index")
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
import DocsLayout from "@layouts/DocsLayout.astro";
|
import DocsLayout from "@layouts/DocsLayout.astro";
|
||||||
import { generateTypeData } from "@config/io/generateTypeData";
|
import { getTypeData } from "@config/io/generateTypeData";
|
||||||
import { processMarkdown } from "@src/config/io/markdown";
|
import { processMarkdown } from "@src/config/io/markdown";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const routes = await generateTypeData();
|
const routes = await getTypeData();
|
||||||
|
|
||||||
return routes
|
return routes
|
||||||
.filter(route => route.name === "index")
|
.filter(route => route.name === "index")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
import DocsLayout from "@layouts/DocsLayout.astro";
|
import DocsLayout from "@layouts/DocsLayout.astro";
|
||||||
import { generateTypeData } from "@config/io/generateTypeData";
|
import { getTypeData } from "@config/io/generateTypeData";
|
||||||
|
|
||||||
const routes = await generateTypeData();
|
const routes = await getTypeData();
|
||||||
|
|
||||||
const modules = [...new Set(routes.map(route => route.type))];
|
const modules = [...new Set(routes.map(route => route.type))];
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in a new issue