-
Notifications
You must be signed in to change notification settings - Fork 12
chore: support configuration for deployment to custom base path #271
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 all commits
07e59cb
e12ebf5
9dfee3d
cdc91d8
5dc4331
74a235f
5223385
703a8f2
bf34eb6
bf80d65
4da6855
fe8a458
8cfbd55
0ee8660
d7400e9
a8e3fda
b22498a
2485093
07bd631
704e28a
3b5f7b8
27edd12
e6b04b8
4ff9368
f783b24
24cb495
3284b85
ead1093
9e544a4
cc243b8
31d439e
6e32f4e
e83c3e0
5f4fe0c
770d3ab
1a12902
acc2fce
24d7eea
89b8576
c3d3002
23aa109
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
public/assets/docs | ||
public/assets | ||
public/docs.json |
This file was deleted.
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, | ||||||||||||||||||
|
@@ -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
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.
Suggested change
Otherwise, it will become In my browser, that URL is interpreted as 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. I have added handling for paths starting with |
||||||||||||||||||
return ( | ||||||||||||||||||
<html lang="ja" class="scroll-pt-24"> | ||||||||||||||||||
<head> | ||||||||||||||||||
|
@@ -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" /> | ||||||||||||||||||
Its-Just-Nans marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
<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'" | ||||||||||||||||||
|
@@ -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> | ||||||||||||||||||
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. |
||||||||||||||||||
|
||||||||||||||||||
<body | ||||||||||||||||||
|
@@ -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"> | ||||||||||||||||||
|
@@ -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"> | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.