Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build-artifacts
path: website/dist
path: website/typst-docs-web/dist
- name: Deploy
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4.7.3
with:
folder: website/dist # The folder the action should deploy.
folder: website/typst-docs-web/dist # The folder the action should deploy.

textlint-md:
runs-on: ubuntu-24.04
Expand All @@ -52,7 +52,7 @@ jobs:
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: build-artifacts
path: website/dist
path: website/typst-docs-web/dist
- uses: jdx/mise-action@13abe502c30c1559a5c37dff303831bab82c9402 # v2.2.3
- name: Install dependencies
run: bun install --frozen-lockfile
Expand All @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: ./website
working-directory: website/typst-docs-web
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .textlintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# hayagrivaのsrc/csl/archive.rsで管理されている参考文献フォーマット
website/dist/reference/model/bibliography/index.html
website/dist/reference/model/cite/index.html
website/typst-docs-web/dist/reference/model/bibliography/index.html
website/typst-docs-web/dist/reference/model/cite/index.html
28 changes: 23 additions & 5 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[tools]
rust = "1.83.0"
node = "22.11.0"
Expand All @@ -11,13 +12,30 @@ idiomatic_version_file_enable_tools = []
[vars]
_.file = "website/metadata.json"

[tasks.symlink-docs-assets]
run = [
"rm -rf website/typst-docs-web/public/docs.json",
"ln -s ../../../docs.json website/typst-docs-web/public/docs.json",
"rm -rf website/typst-docs-web/public/assets",
"ln -s ../../../assets website/typst-docs-web/public/assets"
]

[tasks.symlink-web-metadata]
run = [
"rm -rf website/typst-docs-web/public/metadata.json",
"ln -s ../../metadata.json website/typst-docs-web/public/metadata.json",
"rm -rf website/typst-docs-web/public/translation-status.json",
"ln -s ../../translation-status.json website/typst-docs-web/public/translation-status.json"
]

[tasks.generate-docs]
depends = ["symlink-docs-assets", "symlink-web-metadata"]
run = "cargo run --package typst-docs -- --assets-dir assets --out-file docs.json --base {{vars.basePath}}"

[tasks.generate-web]
depends = ["install-website"]
depends = ["install-website", "symlink-docs-assets", "symlink-web-metadata"]
run = ["bun run build"]
dir = "./website"
dir = "./website/typst-docs-web"

[tasks.generate]
run = [
Expand All @@ -27,17 +45,17 @@ run = [

[tasks.install-website]
run = "bun install --frozen-lockfile"
dir = "./website"
dir = "./website/typst-docs-web"

[tasks.dev]
depends = ["install-website"]
run = "bun run dev"
dir = "./website"
dir = "./website/typst-docs-web"

[tasks.preview]
depends = ["install-website"]
run = "bun run preview"
dir = "./website"
dir = "./website/typst-docs-web"

[tasks.install-textlint]
run = "bun install --frozen-lockfile"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"textlint-md": "textlint ./docs/",
"textlint-md:fix": "textlint --fix ./docs/",
"textlint-html": "textlint ./website/dist/"
"textlint-html": "textlint ./website/typst-docs-web/dist/"
},
"devDependencies": {
"@types/bun": "latest",
Expand Down
4 changes: 0 additions & 4 deletions website/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion website/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "./metadata.schema.json",
"$schema": "./typst-docs-web/metadata.schema.json",
"language": "ja-JP",
"version": "0.13.1",
"typstOfficialUrl": "https://typst.app",
Expand Down
2 changes: 1 addition & 1 deletion website/translation-status.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "./translation-status.schema.json",
"$schema": "./typst-docs-web/translation-status.schema.json",
"/docs/": "translated",
"/docs/tutorial/": "translated",
"/docs/tutorial/writing-in-typst/": "translated",
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions website/typst-docs-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
public/assets
public/docs.json
public/metadata.json
public/translation-status.json
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
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
25 changes: 23 additions & 2 deletions website/src/metadata.ts → website/typst-docs-web/src/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import metadataJson from "../metadata.json";
import fs from "node:fs";
import path from "node:path";

const METADATA_FILE = path.resolve(process.cwd(), "./public/metadata.json");

type Metadata = {
language: "ja-JP" | "en-US";
Expand All @@ -13,7 +16,25 @@ type Metadata = {
displayTranslationStatus: boolean;
};

const metadata = metadataJson as Metadata;
const metadata: Metadata = (() => {
if (fs.existsSync(METADATA_FILE)) {
const content = fs.readFileSync(METADATA_FILE, "utf-8");
return JSON.parse(content);
}
// If metadata JSON file does not exist, fallback for test environments
return {
language: "en-US",
version: "0.0.0",
typstOfficialUrl: "https://typst.app/",
typstOfficialDocsUrl: "https://typst.app/docs/",
githubOrganizationUrl: "https://github.com/typst",
githubRepositoryUrl: "https://github.com/typst/typst",
discordServerUrl: "https://discord.gg/dummy",
originUrl: "https://example.com/",
basePath: "/docs/",
displayTranslationStatus: true,
} satisfies Metadata;
})();

/** The language of the documentation. */
export const language = metadata.language;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type TranslationStatusMap = {

const TRANSLATION_STATUS_FILE = path.resolve(
process.cwd(),
"translation-status.json",
"./public/translation-status.json",
);

/**
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions website/vite.config.ts → website/typst-docs-web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { rmSync, symlinkSync } from "node:fs";
import { resolve } from "node:path";
import { robotsTxtPlugin } from "@hono/ssg-plugins-essential/robots-txt";
import { sitemapPlugin } from "@hono/ssg-plugins-essential/sitemap";
import devServer, { defaultOptions } from "@hono/vite-dev-server";
Expand All @@ -9,18 +7,6 @@ import { defineConfig } from "vite";
import { basePath, 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 publicAssetsDocsPath = resolve(__dirname, "./public/assets/");
rmSync(publicAssetsDocsPath, { recursive: true, force: true });
symlinkSync(assetsDocsPath, publicAssetsDocsPath, "dir");

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

const ssgPlugins =
basePath === "/"
? [
Expand Down