Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion website/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"discordServerUrl": "https://discord.gg/9xF7k4aAuH",
"originUrl": "https://typst-jp.github.io/",
"basePath": "/docs/",
"displayTranslationStatus": true
"displayTranslationStatus": true,
"docsJsonPath": "../../docs.json",
"assetsPath": "../../assets/"
}
12 changes: 11 additions & 1 deletion website/typst-docs-web/metadata.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
"displayTranslationStatus": {
"type": "boolean",
"description": "Indicates whether to display the translation status on the site. Community content is always displayed."
},
"docsJsonPath": {
"type": "string",
"description": "The relative path to docs.json from the SSG project root."
},
"assetsPath": {
"type": "string",
"description": "The relative path to the assets directory from the SSG project root."
}
},
"required": [
Expand All @@ -61,6 +69,8 @@
"discordServerUrl",
"originUrl",
"basePath",
"displayTranslationStatus"
"displayTranslationStatus",
"docsJsonPath",
"assetsPath"
]
}
2 changes: 1 addition & 1 deletion website/typst-docs-web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { serveStatic } from "@hono/node-server/serve-static";
import { Hono } from "hono";
import { appendTrailingSlash, trimTrailingSlash } from "hono/trailing-slash";
// Documentation generated by typst-docs.
import docsJson from "../../../docs.json";
import docsJson from "../public/docs.json";
import {
CategoryTemplate,
FuncTemplate,
Expand Down
6 changes: 6 additions & 0 deletions website/typst-docs-web/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Metadata = {
originUrl: string;
basePath: "/" | `/${string}/`;
displayTranslationStatus: boolean;
docsJsonPath: string;
assetsPath: string;
};

const metadata = metadataJson as Metadata;
Expand All @@ -35,3 +37,7 @@ export const originUrl = metadata.originUrl;
export const basePath = metadata.basePath;
/** Indicates whether to display the translation status on the site. Community content is always displayed. */
export const displayTranslationStatus = metadata.displayTranslationStatus;
/** The relative path to docs.json from the SSG project root. */
export const docsJsonPath = metadata.docsJsonPath;
/** The relative path to the assets directory from the SSG project root. */
export const assetsPath = metadata.assetsPath;
6 changes: 3 additions & 3 deletions website/typst-docs-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import devServer, { defaultOptions } from "@hono/vite-dev-server";
import ssg from "@hono/vite-ssg";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import { basePath, originUrl } from "./src/metadata";
import { assetsPath, basePath, docsJsonPath, originUrl } from "./src/metadata";
import { joinPath } from "./src/utils/path";

// Create a symbolic link to the assets generated by typst-docs in ./public/assets/
const assetsDocsPath = resolve(__dirname, "../../assets/");
const assetsDocsPath = resolve(__dirname, assetsPath);
const publicAssetsDocsPath = resolve(__dirname, "./public/assets/");
rmSync(publicAssetsDocsPath, { recursive: true, force: true });
symlinkSync(assetsDocsPath, publicAssetsDocsPath, "dir");
Copy link
Contributor

@YDX-2147483647 YDX-2147483647 Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about [Option C] letting typst-docs-web always read typst-docs-web/public/, and creating symlinks in mise.toml?

[Option C'] Also creating a symlink from metadata.json to typst-docs-web/public/metadata.json.


// Create a symbolic link to the assets generated by typst-docs in ./public/docs.json
const jsonDocsPath = resolve(__dirname, "../../docs.json");
const jsonDocsPath = resolve(__dirname, docsJsonPath);
const publicJsonDocsPath = resolve(__dirname, "./public/docs.json");
rmSync(publicJsonDocsPath, { recursive: true, force: true });
symlinkSync(jsonDocsPath, publicJsonDocsPath, "file");
Expand Down