mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-21 21:45:42 -05:00
fix: expose base path via data-basepath attribute on body
Compute the base path from cfg.baseUrl and set it as a data attribute on <body> so client-side scripts can resolve links correctly when Quartz is deployed to a subdirectory (e.g., user.github.io/repository).
This commit is contained in:
parent
75aef3b0a9
commit
1b999a792f
@ -266,10 +266,11 @@ export function renderPage(
|
|||||||
|
|
||||||
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
||||||
const direction = i18n(cfg.locale).direction ?? "ltr"
|
const direction = i18n(cfg.locale).direction ?? "ltr"
|
||||||
|
const basePath = cfg.baseUrl ? new URL(`https://${cfg.baseUrl}`).pathname.replace(/\/$/, "") : ""
|
||||||
const doc = (
|
const doc = (
|
||||||
<html lang={lang} dir={direction}>
|
<html lang={lang} dir={direction}>
|
||||||
<Head {...componentData} />
|
<Head {...componentData} />
|
||||||
<body data-slug={slug}>
|
<body data-slug={slug} data-basepath={basePath}>
|
||||||
{frame.css && <style dangerouslySetInnerHTML={{ __html: frame.css }} />}
|
{frame.css && <style dangerouslySetInnerHTML={{ __html: frame.css }} />}
|
||||||
<div id="quartz-root" class="page" data-frame={frame.name}>
|
<div id="quartz-root" class="page" data-frame={frame.name}>
|
||||||
<Body {...componentData}>
|
<Body {...componentData}>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user