Skip to content

Commit bf45a04

Browse files
committed
refactor: use metadata constants for all absolute URLs
1 parent 9f4379b commit bf45a04

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

website/src/components/templates/BaseTemplate.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FC, PropsWithChildren } from "hono/jsx";
2+
import { baseUrl, typstOfficialUrl } from "../../metadata";
23
import type { Page } from "../../types/model";
34
import { getTranslationStatus } from "../../utils/translationStatus";
45
import {
@@ -41,6 +42,9 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
4142
const route = page.route;
4243
const outline = page.outline;
4344
const translationStatus = getTranslationStatus(route);
45+
const absoluteRouteUrl = new URL(route, baseUrl).toString();
46+
const faviconUrl = new URL("/assets/favicon.png", baseUrl).toString();
47+
const typstOfficialRouteUrl = new URL(route, typstOfficialUrl).toString();
4448
return (
4549
<html lang="ja" class="scroll-pt-24">
4650
<head>
@@ -49,26 +53,20 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
4953
<meta name="description" content={description} />
5054
<meta name="viewport" content="width=device-width,initial-scale=1" />
5155
<meta name="theme-color" content="#239dad" />
52-
<meta
53-
property="og:url"
54-
content={`https://typst-jp.github.io${route}`}
55-
/>
56+
<meta property="og:url" content={absoluteRouteUrl} />
5657
<meta
5758
property="og:title"
5859
content={`${title} – Typstドキュメント日本語版`}
5960
/>
6061
<meta property="og:site_name" content="Typst" />
6162
<meta property="og:description" content={description} />
6263
<meta property="og:type" content="" />
63-
<meta
64-
property="og:image"
65-
content="https://typst-jp.github.io/assets/favicon.png"
66-
/>
64+
<meta property="og:image" content={faviconUrl} />
6765
<meta property="og:image:width" content="1200" />
6866
<meta property="og:image:height" content="630" />
6967
<meta name="twitter:site" content="@typstapp" />
7068
<meta name="twitter:card" content="summary_large_image" />
71-
<link rel="canonical" href={`https://typst-jp.github.io${route}`} />
69+
<link rel="canonical" href={absoluteRouteUrl} />
7270
<meta name="robots" content="index, follow" />
7371
<link rel="sitemap" type="application/xml" href="/sitemap.xml" />
7472
<meta
@@ -184,7 +182,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
184182
{translationStatus !== "community" && (
185183
<div class="flex">
186184
<a
187-
href={`https://typst.app${route}`}
185+
href={typstOfficialRouteUrl}
188186
target="_blank"
189187
rel="noopener noreferrer"
190188
class="inline-flex items-center text-sm underline text-gray-400 hover:text-gray-600 transition-colors"
@@ -203,7 +201,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
203201

204202
{translationStatus !== "community" && (
205203
<a
206-
href={`https://typst.app${route}`}
204+
href={typstOfficialRouteUrl}
207205
target="_blank"
208206
rel="noopener noreferrer"
209207
class="group inline-flex items-center px-3 py-2 rounded-md border border-gray-200 bg-white hover:border-gray-500 hover:bg-gray-50 transition-all duration-200 w-fit"

0 commit comments

Comments
 (0)