Skip to content

Commit

Permalink
Migrate PageLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Dec 28, 2024
1 parent 79163e1 commit 183c5cb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 52 deletions.
12 changes: 0 additions & 12 deletions app/elements/page-layout.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions app/pages/$$.mjs

This file was deleted.

3 changes: 0 additions & 3 deletions app/pages/404.html

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect } from 'preact/hooks'
import Layout from './Layout'

export default function PageLayout({
title,
children,
}: {
title: string
children: preact.ComponentChildren
}) {
useEffect(() => {
document.title = `${title} | SeattleJS`
}, [title])

return (
<Layout>
<div id="page">
<div class="page-title">
<h1>{title}</h1>
</div>
<div class="page-body">{children}</div>
</div>
</Layout>
)
}
26 changes: 7 additions & 19 deletions src/utils/createMarkdownRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect } from 'preact/hooks'
import Layout from '../components/Layout'
import { memo } from './memo'
import PageLayout from '../components/PageLayout'

export async function createMarkdownRoute(
markdownPath: string
Expand All @@ -17,24 +16,13 @@ export async function createMarkdownRoute(
const html = await marked.marked(body)

function MarkdownRoute() {
useEffect(() => {
document.title = `${attributes.title} | SeattleJS`
}, [])

return (
<Layout>
<div id="page">
<div class="page-title">
<div>
<h1>{attributes.title}</h1>
</div>
</div>
<div
class="page-body"
dangerouslySetInnerHTML={{ __html: html }}
></div>
</div>
</Layout>
<PageLayout title={attributes.title}>
<div
class="markdown-content"
dangerouslySetInnerHTML={{ __html: html }}
></div>
</PageLayout>
)
}

Expand Down

0 comments on commit 183c5cb

Please sign in to comment.