mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(site): keep the page when leaving the Markdown view on static pages (#63503)
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
cbcd846a57
commit
d7ae4f2e3c
@@ -36,10 +36,18 @@ export async function toggle(on = !dispose, fromFooter = false) {
|
||||
if (text === undefined || dispose) return
|
||||
const file = href()!.split("/").pop()!
|
||||
const home = $<HTMLAnchorElement>('[data-slot="logo"]')?.getAttribute("href") ?? "/"
|
||||
dispose = await mount(
|
||||
// Its own host after the page: disposing a render empties its host, which must not take the page.
|
||||
const host = document.createElement("div")
|
||||
host.style.display = "contents"
|
||||
$('[data-component="content"]')!.append(host)
|
||||
const unmount = await mount(
|
||||
() => <MarkdownView source={text} file={file} href={href()} home={home} onHome={() => void toggle(false)} />,
|
||||
$('[data-component="content"]')!,
|
||||
host,
|
||||
)
|
||||
dispose = () => {
|
||||
unmount()
|
||||
host.remove()
|
||||
}
|
||||
sessionStorage.setItem(markdownKey, "1")
|
||||
show(true, fromFooter)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user