feat(i18n): homepage link for 404 pages ()

* Add homepage link with internationalization

* Construct pathname from baseUrl config value

* More robust URL manipulation

* Add Farsi ()

* Fix bad rebase
This commit is contained in:
James Bennion-Pedley 2024-05-22 21:44:54 +01:00 committed by GitHub
parent 81a4e20236
commit 9c726efa33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 24 additions and 0 deletions
quartz/components/pages

View file

@ -2,10 +2,15 @@ import { i18n } from "../../i18n"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
const NotFound: QuartzComponent = ({ cfg }: QuartzComponentProps) => {
// If baseUrl contains a pathname after the domain, use this as the home link
const url = new URL(`https://${cfg.baseUrl ?? "example.com"}`)
const baseDir = url.pathname
return (
<article class="popover-hint">
<h1>404</h1>
<p>{i18n(cfg.locale).pages.error.notFound}</p>
<a href={baseDir}>{i18n(cfg.locale).pages.error.home}</a>
</article>
)
}