- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13
chore: add metadata JSON file for website configuration #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
faa41bb
              00f2f99
              95121ba
              0e7b6c0
              69e3ccb
              cdb4c9f
              94fc303
              f9af723
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "$schema": "./metadata.schema.json", | ||
| "language": "ja-JP", | ||
| "version": "0.13.1", | ||
| "typstOfficialUrl": "https://typst.app", | ||
| "typstOfficialDocsUrl": "https://typst.app/docs/", | ||
| "githubOrganizationUrl": "https://github.com/typst-jp", | ||
| "githubRepositoryUrl": "https://github.com/typst-jp/docs", | ||
| "discordServerUrl": "https://discord.gg/9xF7k4aAuH", | ||
| "originUrl": "https://typst-jp.github.io/", | ||
| "basePath": "/docs/", | ||
| "displayTranslationStatus": true | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "type": "object", | ||
| "properties": { | ||
| "language": { | ||
| "type": "string", | ||
| "description": "The language of the documentation.", | ||
| "enum": ["ja-JP", "en-US"] | ||
| }, | ||
| "version": { | ||
| "type": "string", | ||
| "description": "The version of the documentation, without a leading 'v'." | ||
| }, | ||
| "typstOfficialUrl": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "description": "The official Typst website URL." | ||
| }, | ||
| "typstOfficialDocsUrl": { | ||
| "type": "string", | ||
| "description": "The official Typst documentation base URL.", | ||
| "pattern": "^https?://.+/$" | ||
| }, | ||
| "githubOrganizationUrl": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "description": "The GitHub organization URL." | ||
| }, | ||
| "githubRepositoryUrl": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "description": "The GitHub repository URL." | ||
| }, | ||
| "discordServerUrl": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "description": "The Discord server invite URL." | ||
| }, | ||
| "originUrl": { | ||
| "type": "string", | ||
| "format": "uri", | ||
| "description": "The origin URL of the deployed site, used for metadata. Note that the base path should not be included." | ||
| }, | ||
| "basePath": { | ||
| "type": "string", | ||
| "description": "The base public path for deployment. This must match the value used in typst-docs.", | ||
| "pattern": "^/$|^/([^/]+/)+$" | ||
| }, | ||
| "displayTranslationStatus": { | ||
| "type": "boolean", | ||
| "description": "Indicates whether to display the translation status on the site. Community content is always displayed." | ||
| } | ||
| }, | ||
| "required": [ | ||
| "language", | ||
| "version", | ||
| "typstOfficialUrl", | ||
| "typstOfficialDocsUrl", | ||
| "githubOrganizationUrl", | ||
| "githubRepositoryUrl", | ||
| "discordServerUrl", | ||
| "originUrl", | ||
| "basePath", | ||
| "displayTranslationStatus" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| { | ||
| "private": true, | ||
| "version": "0.13.1", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite dev", | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,22 +1,37 @@ | ||
| import { version } from "../package.json"; | ||
| import metadataJson from "../metadata.json"; | ||
|  | ||
| // TODO: The metadata will be configurable via a JSON configuration file. | ||
| type Metadata = { | ||
| language: "ja-JP" | "en-US"; | ||
| version: string; | ||
| typstOfficialUrl: string; | ||
| typstOfficialDocsUrl: `http://${string}/` | `https://${string}/`; | ||
| githubOrganizationUrl: string; | ||
| githubRepositoryUrl: string; | ||
| discordServerUrl: string; | ||
| originUrl: string; | ||
| basePath: "/" | `/${string}/`; | ||
| displayTranslationStatus: boolean; | ||
| }; | ||
|  | ||
| const metadata = metadataJson as Metadata; | ||
|  | ||
| /** The language of the documentation. */ | ||
| export const language = metadata.language; | ||
| /** The version of the documentation, without a leading `v`. */ | ||
| export { version }; | ||
| export const version = metadata.version; | ||
| /** The official Typst website URL. */ | ||
| export const typstOfficialUrl = "https://typst.app"; | ||
| export const typstOfficialUrl = metadata.typstOfficialUrl; | ||
| /** The official Typst documentation base URL. */ | ||
| export const typstOfficialDocsUrl: `http://${string}/` | `https://${string}/` = | ||
| "https://typst.app/docs/"; | ||
| export const typstOfficialDocsUrl = metadata.typstOfficialDocsUrl; | ||
| /** The GitHub organization URL. */ | ||
| export const githubOrganizationUrl = "https://github.com/typst-jp"; | ||
| export const githubOrganizationUrl = metadata.githubOrganizationUrl; | ||
| /** The GitHub repository URL. */ | ||
| export const githubRepositoryUrl = "https://github.com/typst-jp/docs"; | ||
| export const githubRepositoryUrl = metadata.githubRepositoryUrl; | ||
| /** The Discord server invite URL. */ | ||
| export const discordServerUrl = "https://discord.gg/9xF7k4aAuH"; | ||
| export const discordServerUrl = metadata.discordServerUrl; | ||
| /** The origin URL of the deployed site, used for metadata. Note that the base path should not be included. */ | ||
| export const originUrl = "https://typst-jp.github.io/"; | ||
| export const originUrl = metadata.originUrl; | ||
| /** The base public path for deployment. This must match the value used in typst-docs. */ | ||
| export const basePath: "/" | `/${string}/` = "/docs/"; | ||
| export const basePath = metadata.basePath; | ||
| /** Indicates whether to display the translation status on the site. Community content is always displayed. */ | ||
| export const displayTranslationStatus: boolean = true; | ||
| export const displayTranslationStatus = metadata.displayTranslationStatus; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| import type { FC } from "hono/jsx"; | ||
| import type { TooltipProps } from "../components/ui/Tooltip"; | ||
| import { language } from "../metadata"; | ||
| import { | ||
| Translation as EnUSTranslation, | ||
| translation as enUSTranslation, | ||
| } from "./en-US"; | ||
| import { | ||
| Translation as JaJPTranslation, | ||
| translation as jaJPTranslation, | ||
| } from "./ja-JP"; | ||
|  | ||
| /** | ||
| * Translation dictionary for UI attributes and aria labels. | ||
|  | @@ -80,7 +89,15 @@ export type TranslationComponentProps = | |
| */ | ||
| export type TranslationComponent = FC<TranslationComponentProps>; | ||
|  | ||
| /** | ||
| * Switch translation language here. | ||
| */ | ||
| export { Translation, translation } from "./ja-JP"; | ||
| // Switch translation language. | ||
| const { Translation, translation } = (() => { | ||
| switch (language) { | ||
| case "ja-JP": | ||
| return { Translation: JaJPTranslation, translation: jaJPTranslation }; | ||
| case "en-US": | ||
| return { Translation: EnUSTranslation, translation: enUSTranslation }; | ||
| default: | ||
| throw new Error(`Unsupported language: ${language}`); | ||
| } | ||
| })(); | ||
| export { Translation, translation }; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If properly set up, then this can be simplified to  https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars Properly set up: 
 | ||
Uh oh!
There was an error while loading. Please reload this page.