Make Zyphos site a single graph app
This commit is contained in:
parent
799303b847
commit
dc87702cc1
6 changed files with 88 additions and 32 deletions
|
|
@ -5,10 +5,6 @@ societies. It is a nested web of memory-bearing contracts. A cell, wound, herd,
|
|||
route, reef, breeding ground, and nation can all be political at their own scale
|
||||
without becoming the same kind of mind.
|
||||
|
||||
<link rel="stylesheet" href="/static/epiphany-graph/assets/viewer.css" />
|
||||
<div class="zyphos-epiphany-graph-root"></div>
|
||||
<script type="module" src="/static/epiphany-graph/assets/viewer.js"></script>
|
||||
|
||||
## Scale Bands
|
||||
|
||||
### Cellular and Microbial
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -152,6 +152,25 @@ function parseHashSelection(slugs: Set<string>): ViewerSelection | null {
|
|||
}
|
||||
}
|
||||
|
||||
function currentRouteSelection(slugs: Set<string>): ViewerSelection | null {
|
||||
const bodySlug = document.body.dataset.slug
|
||||
const pathSlug = decodeURIComponent(window.location.pathname)
|
||||
.replace(/^\//, "")
|
||||
.replace(/\.html$/, "")
|
||||
.replace(/\/$/, "/index")
|
||||
const slug = normalizeSlug(bodySlug || pathSlug || "index")
|
||||
|
||||
if (!slugs.has(slug)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "node",
|
||||
graphKey: "architecture",
|
||||
nodeId: slug,
|
||||
}
|
||||
}
|
||||
|
||||
function compareSections(left: string, right: string) {
|
||||
const leftIndex = SECTION_ORDER.indexOf(left)
|
||||
const rightIndex = SECTION_ORDER.indexOf(right)
|
||||
|
|
@ -396,11 +415,14 @@ function App() {
|
|||
const nextSlugs = new Set(Object.keys(nextContentIndex).map(normalizeSlug))
|
||||
setContentIndex(nextContentIndex)
|
||||
setGraphState(nextGraphState)
|
||||
setSelection(parseHashSelection(nextSlugs) ?? {
|
||||
kind: "node",
|
||||
graphKey: "architecture",
|
||||
nodeId: nextSlugs.has("index") ? "index" : nextGraphState.architecture.nodes[0]?.id ?? "",
|
||||
})
|
||||
setSelection(
|
||||
parseHashSelection(nextSlugs) ??
|
||||
currentRouteSelection(nextSlugs) ?? {
|
||||
kind: "node",
|
||||
graphKey: "architecture",
|
||||
nodeId: nextSlugs.has("index") ? "index" : nextGraphState.architecture.nodes[0]?.id ?? "",
|
||||
},
|
||||
)
|
||||
}
|
||||
})
|
||||
.catch((caught) => {
|
||||
|
|
@ -493,7 +515,7 @@ function App() {
|
|||
onSelectionChange={setSelection}
|
||||
overlayPanels
|
||||
className="zyphos-graph-shell"
|
||||
sidebarWidth="minmax(360px, 44vw)"
|
||||
sidebarWidth="50vw"
|
||||
sidebar={
|
||||
<ArticlePanel
|
||||
articleState={articleState}
|
||||
|
|
@ -605,9 +627,6 @@ function ArticlePanel({
|
|||
<header className="zyphos-spa-article-header">
|
||||
<p className="zyphos-spa-kicker">{sectionForSlug(noteSlug)}</p>
|
||||
<h1>{entryTitle(noteSlug, note)}</h1>
|
||||
<div className="zyphos-spa-actions">
|
||||
<a href={slugToArticleUrl(noteSlug)}>Open page</a>
|
||||
</div>
|
||||
</header>
|
||||
{articleState.status === "loading" && <div className="zyphos-spa-status">Loading article...</div>}
|
||||
{articleState.status === "error" && (
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ import { PageLayout, SharedLayout } from "./quartz/cfg"
|
|||
import * as Component from "./quartz/components"
|
||||
import ZyphosMasthead from "./quartz/components/ZyphosMasthead"
|
||||
import ZyphosOverviewSidebar from "./quartz/components/ZyphosOverviewSidebar"
|
||||
import ZyphosGraphShell from "./quartz/components/ZyphosGraphShell"
|
||||
import ZyphosSinglePageRedirect from "./quartz/components/ZyphosSinglePageRedirect"
|
||||
import ZyphosThemeLock from "./quartz/components/ZyphosThemeLock"
|
||||
|
||||
export const sharedPageComponents: SharedLayout = {
|
||||
head: Component.Head(),
|
||||
header: [ZyphosThemeLock(), ZyphosMasthead(), Component.Search()],
|
||||
header: [ZyphosSinglePageRedirect(), ZyphosThemeLock(), ZyphosMasthead(), Component.Search()],
|
||||
afterBody: [],
|
||||
footer: Component.Footer({
|
||||
links: {},
|
||||
|
|
@ -32,7 +34,12 @@ export const defaultContentPageLayout: PageLayout = {
|
|||
condition: (page) => !page.fileData.slug?.endsWith("/index") && page.fileData.slug !== "index",
|
||||
}),
|
||||
],
|
||||
afterBody: [],
|
||||
afterBody: [
|
||||
Component.ConditionalRender({
|
||||
component: ZyphosGraphShell(),
|
||||
condition: (page) => page.fileData.slug === "index",
|
||||
}),
|
||||
],
|
||||
left: [ZyphosOverviewSidebar()],
|
||||
right: [
|
||||
Component.DesktopOnly(Component.TableOfContents()),
|
||||
|
|
|
|||
13
site/quartz/components/ZyphosGraphShell.tsx
Normal file
13
site/quartz/components/ZyphosGraphShell.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { QuartzComponent, QuartzComponentConstructor } from "./types"
|
||||
|
||||
export default (() => {
|
||||
const ZyphosGraphShell: QuartzComponent = () => (
|
||||
<>
|
||||
<link rel="stylesheet" href="/static/epiphany-graph/assets/viewer.css" />
|
||||
<div class="zyphos-epiphany-graph-root"></div>
|
||||
<script type="module" src="/static/epiphany-graph/assets/viewer.js"></script>
|
||||
</>
|
||||
)
|
||||
|
||||
return ZyphosGraphShell
|
||||
}) satisfies QuartzComponentConstructor
|
||||
21
site/quartz/components/ZyphosSinglePageRedirect.tsx
Normal file
21
site/quartz/components/ZyphosSinglePageRedirect.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||
|
||||
export default (() => {
|
||||
const ZyphosSinglePageRedirect: QuartzComponent = ({ fileData }: QuartzComponentProps) => {
|
||||
const slug = fileData.slug ?? "index"
|
||||
|
||||
if (slug === "index") {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.location.replace("/#note=${encodeURIComponent(slug)}")`,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return ZyphosSinglePageRedirect
|
||||
}) satisfies QuartzComponentConstructor
|
||||
Loading…
Reference in a new issue