Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
07e59cb
remvoe /docs
Its-Just-Nans Aug 15, 2025
e12ebf5
chore: move static assets to the root directory
3w36zj6 Aug 17, 2025
9dfee3d
chore: update routing and asset paths
3w36zj6 Aug 17, 2025
cdc91d8
feat: update top page links to use base path
3w36zj6 Aug 17, 2025
5dc4331
fix: pagefind
Its-Just-Nans Aug 17, 2025
74a235f
fix dev server
Its-Just-Nans Aug 17, 2025
5223385
fix: plugins
Its-Just-Nans Aug 17, 2025
703a8f2
biome check
Its-Just-Nans Aug 17, 2025
bf34eb6
fix: dev server
Its-Just-Nans Aug 17, 2025
bf80d65
fix path
Its-Just-Nans Aug 17, 2025
4da6855
fix: remove sitemap link element
3w36zj6 Aug 17, 2025
fe8a458
fix: correction
Its-Just-Nans Aug 17, 2025
8cfbd55
chore: update vite version to ^7.1.2
3w36zj6 Aug 18, 2025
0ee8660
chore: update @hono/vite-dev-server version to ^0.20.1
3w36zj6 Aug 18, 2025
d7400e9
chore: inject Vite client script manually
3w36zj6 Aug 18, 2025
a8e3fda
Merge remote-tracking branch 'origin/main' into wip
3w36zj6 Aug 18, 2025
b22498a
chore: update path for generated documentation
3w36zj6 Aug 18, 2025
2485093
chore: add `public/assets` directory to `.gitignore`
3w36zj6 Aug 19, 2025
07bd631
feat: add path utility
3w36zj6 Aug 19, 2025
704e28a
refactor: replace string concatenation with path utility for URL cons…
3w36zj6 Aug 19, 2025
3b5f7b8
docs: add TSDoc to metadata
3w36zj6 Aug 19, 2025
27edd12
feat: add route validation
3w36zj6 Aug 19, 2025
e6b04b8
refactor: move global styles to CSS file
3w36zj6 Aug 19, 2025
4ff9368
fix: update Typst official URL handling in base template
3w36zj6 Aug 19, 2025
f783b24
refactor: add utility to remove base path
3w36zj6 Aug 19, 2025
24cb495
fix message
Its-Just-Nans Aug 20, 2025
3284b85
symlink docs.json
Its-Just-Nans Aug 20, 2025
ead1093
disable PagefinUi on dev
Its-Just-Nans Aug 20, 2025
9e544a4
biome :)
Its-Just-Nans Aug 20, 2025
cc243b8
I missed an update of mise
Its-Just-Nans Aug 20, 2025
31d439e
Update website/src/components/templates/BaseTemplate.tsx
3w36zj6 Aug 20, 2025
6e32f4e
Update website/src/metadata.ts
3w36zj6 Aug 20, 2025
e83c3e0
Update website/src/metadata.ts
3w36zj6 Aug 20, 2025
5f4fe0c
refactor: remove hardcoded path
3w36zj6 Aug 22, 2025
770d3ab
style: apply Biome
3w36zj6 Aug 22, 2025
1a12902
fix: update base path type to enforce leading and trailing slash
3w36zj6 Aug 22, 2025
acc2fce
fix: allow root path in base path type
3w36zj6 Aug 22, 2025
24d7eea
fix: add official documentation base URL type
3w36zj6 Aug 22, 2025
89b8576
fix: handle joining of paths when the first part is a `http(s)://` URL
3w36zj6 Aug 22, 2025
c3d3002
style: apply Biome
3w36zj6 Aug 22, 2025
23aa109
Merge remote-tracking branch 'origin/main' into remove-docs-url
3w36zj6 Aug 22, 2025
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
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ package-lock.json
/result
.direnv/

# Documentation
/assets/docs
/assets/docs.json
# Generated documentation
/assets
/docs.json
7 changes: 2 additions & 5 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ yes = true
idiomatic_version_file_enable_tools = []

[tasks.generate-docs]
run = "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture"
run = "cargo run --package typst-docs -- --assets-dir assets --out-file docs.json --base /docs/"

[tasks.generate-web]
depends = ["install-website"]
run = [
"bun install --frozen-lockfile",
"bun run build",
]
run = ["bun run build"]
dir = "./website"

[tasks.generate]
Expand Down
3 changes: 2 additions & 1 deletion website/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
public/assets/docs
public/assets
public/docs.json
Binary file modified website/bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"dev": "vite dev",
"build": "vite build && npm run update-search-index",
"preview": "vite preview",
"update-search-index": "pagefind --site ./dist/ --glob \"docs/**/*.html\"",
"update-search-index": "pagefind --site ./dist/ --glob \"**/*.html\"",
"check": "biome check .",
"check:write": "biome check --write .",
"test": "vitest"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@hono/ssg-plugins-essential": "^0.1.0",
"@hono/vite-dev-server": "^0.19.0",
"@hono/vite-dev-server": "^0.20.1",
"@hono/vite-ssg": "^0.2.0",
"@tailwindcss/typography": "^0.5.16",
"@tailwindcss/vite": "^4.1.5",
Expand All @@ -23,7 +23,7 @@
"pagefind": "^1.3.0",
"tailwind-merge": "^3.3.0",
"tailwindcss": "^4.1.5",
"vite": "^6.2.5",
"vite": "^7.1.2",
"vitest": "^3.1.4"
}
}
File renamed without changes
3 changes: 0 additions & 3 deletions website/public/index.html

This file was deleted.

56 changes: 42 additions & 14 deletions website/src/components/templates/BaseTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { html } from "hono/html";
import type { FC, PropsWithChildren } from "hono/jsx";
import { baseUrl, typstOfficialUrl } from "../../metadata";
import { basePath, originUrl, typstOfficialDocsUrl } from "../../metadata";
import type { Page } from "../../types/model";
import { joinPath, removeBasePath } from "../../utils/path";
import { getTranslationStatus } from "../../utils/translationStatus";
import {
CaretRightCircleIcon,
Expand Down Expand Up @@ -42,9 +44,15 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
const route = page.route;
const outline = page.outline;
const translationStatus = getTranslationStatus(route);
const absoluteRouteUrl = new URL(route, baseUrl).toString();
const faviconUrl = new URL("/assets/favicon.png", baseUrl).toString();
const typstOfficialRouteUrl = new URL(route, typstOfficialUrl).toString();
const absoluteRouteUrl = new URL(route, originUrl).toString();
const faviconUrl = new URL(
joinPath(basePath, "/favicon.png"),
originUrl,
).toString();
const typstOfficialRouteUrl = joinPath(
typstOfficialDocsUrl,
removeBasePath(basePath, route),
);
Comment on lines +52 to +55
Copy link
Contributor

@YDX-2147483647 YDX-2147483647 Aug 22, 2025

Choose a reason for hiding this comment

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

Suggested change
const typstOfficialRouteUrl = joinPath(
typstOfficialDocsUrl,
removeBasePath(basePath, route),
);
const typstOfficialRouteUrl = new URL(
removeBasePath(basePath, route).replace(/^\//, ""),
typstOfficialDocsUrl,
).toString();

Otherwise, it will become https:/typst.app/docs/reference/context/, where https:// is transformed into https:/.

In my browser, that URL is interpreted as http://localhost:4173/typst.app/docs/reference/context/, though I don't know why…

Copy link
Member

Choose a reason for hiding this comment

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

I have added handling for paths starting with http(s)://. 89b8576

return (
<html lang="ja" class="scroll-pt-24">
<head>
Expand All @@ -68,7 +76,6 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
<meta name="twitter:card" content="summary_large_image" />
<link rel="canonical" href={absoluteRouteUrl} />
<meta name="robots" content="index, follow" />
<link rel="sitemap" type="application/xml" href="/sitemap.xml" />
<meta
name="twitter:image:alt"
content="The left side of a text editor with colorful cursors, as well as the text 'Compose papers faster, Typst'"
Expand All @@ -77,46 +84,67 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
rel="icon"
type="image/png"
sizes="32x32"
href="/assets/favicon.png"
href={joinPath(basePath, "/favicon.png")}
/>
<link
rel="preload"
href="/assets/fonts/hanken-grotesk/HKGrotesk-Regular.woff2"
href={joinPath(
basePath,
"/fonts/hanken-grotesk/HKGrotesk-Regular.woff2",
)}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/assets/fonts/hanken-grotesk/HKGrotesk-Bold.woff2"
href={joinPath(
basePath,
"/fonts/hanken-grotesk/HKGrotesk-Bold.woff2",
)}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/assets/fonts/hanken-grotesk/HKGrotesk-SemiBold.woff2"
href={joinPath(
basePath,
"/fonts/hanken-grotesk/HKGrotesk-SemiBold.woff2",
)}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/assets/fonts/cascadia-code/CascadiaMono-Regular-Sub.woff2"
href={joinPath(
basePath,
"/fonts/cascadia-code/CascadiaMono-Regular-Sub.woff2",
)}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<link
href={
import.meta.env.DEV ? "/src/globals.css" : "/assets/globals.css"
import.meta.env.DEV
? joinPath(basePath, "/src/globals.css")
: joinPath(basePath, "/globals.css")
}
rel="stylesheet"
/>
<script
defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"
/>
{/* NOTE: @hono/vite-dev-server does not respect the base setting in the Vite configuration. */}
{import.meta.env.DEV &&
html`
<script>
import("${joinPath(basePath, "/@vite/client")}")
</script>
`}
</head>
Copy link
Contributor

Choose a reason for hiding this comment

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


<body
Expand Down Expand Up @@ -218,11 +246,11 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
</a>
)}

{route === "/docs/" ? (
{route === basePath ? (
<div class="doc-categories grid grid-cols-1 md:grid-cols-2 gap-6 mt-8">
<a
class="doc-category flex flex-col p-6 bg-white border border-gray-200 rounded-lg hover:border-gray-500 hover:bg-gray-50 transition-all duration-200"
href="/docs/tutorial"
href={joinPath(basePath, "/tutorial/")}
>
<div class="flex items-center mb-3">
<div class="w-6 h-6 text-gray-800 mr-2">
Expand All @@ -238,7 +266,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
</a>
<a
class="doc-category flex flex-col p-6 bg-white border border-gray-200 rounded-lg hover:border-gray-500 hover:bg-gray-50 transition-all duration-200"
href="/docs/reference"
href={joinPath(basePath, "/reference/")}
>
<div class="flex items-center mb-3">
<div class="w-6 h-6 text-gray-800 mr-2">
Expand Down
10 changes: 8 additions & 2 deletions website/src/components/ui/FunctionDefinition.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { FC } from "hono/jsx";
import { basePath } from "../../metadata";
import type { Func } from "../../types/model";
import { joinPath } from "../../utils/path";
import { TypeIcon } from "./TypeIcon";
import { genPath } from "./genPath";
import { buildParamId, type2href } from "./type2href";
Expand Down Expand Up @@ -48,7 +50,9 @@ export const FunctionDefinition: FC<FunctionDefinitionProps> = ({
<TypeIcon
key={t}
type={t}
href={href ? `/docs/reference/${href}` : undefined}
href={
href ? joinPath(basePath, "reference", href) : undefined
}
/>
);
})}
Expand All @@ -72,7 +76,9 @@ export const FunctionDefinition: FC<FunctionDefinitionProps> = ({
<TypeIcon
key={ret}
type={ret}
href={href ? `/docs/reference/${href}` : undefined}
href={
href ? joinPath(basePath, "reference", href) : undefined
}
/>
{i < func.returns.length - 1 && (
<span class="text-gray-500 mx-1">,</span>
Expand Down
6 changes: 5 additions & 1 deletion website/src/components/ui/FunctionParameters.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { FC } from "hono/jsx";
import { basePath } from "../../metadata";
import type { Func } from "../../types/model";
import { joinPath } from "../../utils/path";
import { ChevronRightIcon } from "../icons";
import { HtmlContent } from "./HtmlContent";
import { Tooltip } from "./Tooltip";
Expand Down Expand Up @@ -40,7 +42,9 @@ export const FunctionParameters: FC<FunctionParametersProps> = ({
<TypeIcon
key={t}
type={t}
href={href ? `/docs/reference/${href}` : undefined}
href={
href ? joinPath(basePath, "reference", href) : undefined
}
/>
);
})}
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/ui/common/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { basePath } from "../../../metadata";
import type { Page } from "../../../types/model";
import { ChevronRightIcon, HomeIcon } from "../../icons";

Expand All @@ -10,7 +11,7 @@ export const Breadcrumbs = ({ path }: BreadcrumbsProps) => {
<nav class="flex justify-between px-3.5 py-1 border border-neutral-200/60 rounded-md">
<ol class="inline-flex flex-wrap items-center space-x-1 text-sm text-gray-600">
<li class="flex items-center h-full">
<a href="/docs/" class="py-1 hover:text-gray-800 transition-colors">
<a href={basePath} class="py-1 hover:text-gray-800 transition-colors">
<div class="w-4 h-4">
<HomeIcon />
</div>
Expand Down
30 changes: 22 additions & 8 deletions website/src/components/ui/common/SearchWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import type { FC } from "hono/jsx";
import { basePath } from "../../../metadata";
import { joinPath } from "../../../utils/path";
import { CloseIcon } from "../../icons";

export const SearchWindow: FC = () => {
return (
<div class="flex flex-col max-h-[80vh]">
<link href="/pagefind/pagefind-ui.css" rel="stylesheet" />
<script src="/pagefind/pagefind-ui.js" />
{import.meta.env.PROD && (
<>
<link
href={joinPath(basePath, "/pagefind/pagefind-ui.css")}
rel="stylesheet"
/>
<script src={joinPath(basePath, "/pagefind/pagefind-ui.js")} />
</>
)}
<div class="flex justify-between items-center p-4 border-b border-gray-200 flex-shrink-0">
<h2 class="text-lg font-semibold">検索</h2>
<button
Expand All @@ -20,17 +29,22 @@ export const SearchWindow: FC = () => {
</button>
</div>
<div class="p-4 overflow-y-auto flex-1">
{import.meta.env.DEV && (
<p>Search is disabled in the development environment.</p>
)}
<div id="search" />
</div>
<script
// biome-ignore lint/security/noDangerouslySetInnerHtml: pagefindで生成されたスクリプトを実行する
dangerouslySetInnerHTML={{
__html: `window.addEventListener('DOMContentLoaded', (event) => {
{!import.meta.env.DEV && (
<script
// biome-ignore lint/security/noDangerouslySetInnerHtml: pagefindで生成されたスクリプトを実行する
dangerouslySetInnerHTML={{
__html: `window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
`,
}}
/>
}}
/>
)}
</div>
);
};
3 changes: 2 additions & 1 deletion website/src/components/ui/common/SiteTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { basePath } from "../../../metadata";
export const SiteTitle = () => {
return (
<a href="/docs" class="logo-box hover:opacity-80 transition-opacity">
<a href={basePath} class="logo-box hover:opacity-80 transition-opacity">
<div class="flex items-baseline">
<span class="text-base font-bold text-teal-600">Typst</span>
<span class="text-base font-medium text-gray-600 ml-1">
Expand Down
8 changes: 4 additions & 4 deletions website/src/components/ui/type2href.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ export const type2href = (parameterType: string): string | null => {
const introspectionSet = new Set(["counter", "location", "state"]);

if (foundationSet.has(parameterType)) {
return `foundations/${parameterType}`;
return `foundations/${parameterType}/`;
}
if (layoutSet.has(parameterType)) {
return `layout/${parameterType}`;
return `layout/${parameterType}/`;
}
if (visualizeSet.has(parameterType)) {
return `visualize/${parameterType}`;
return `visualize/${parameterType}/`;
}
if (introspectionSet.has(parameterType)) {
return `introspection/${parameterType}`;
return `introspection/${parameterType}/`;
}
return null;
};
Expand Down
10 changes: 4 additions & 6 deletions website/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,31 @@
/* Global font family */
@font-face {
font-family: "HK Grotesk";
src: url("/assets/fonts/hanken-grotesk/HKGrotesk-Regular.woff2")
format("woff2");
src: url("/fonts/hanken-grotesk/HKGrotesk-Regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "HK Grotesk";
src: url("/assets/fonts/hanken-grotesk/HKGrotesk-SemiBold.woff2")
format("woff2");
src: url("/fonts/hanken-grotesk/HKGrotesk-SemiBold.woff2") format("woff2");
font-weight: 600;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "HK Grotesk";
src: url("/assets/fonts/hanken-grotesk/HKGrotesk-Bold.woff2") format("woff2");
src: url("/fonts/hanken-grotesk/HKGrotesk-Bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "Cascadia Mono";
src: url("/assets/fonts/cascadia-code/CascadiaMono-Regular-Sub.woff2")
src: url("/fonts/cascadia-code/CascadiaMono-Regular-Sub.woff2")
format("woff2");
font-weight: 400;
font-style: normal;
Expand Down
Loading