add titles to pages
This commit is contained in:
parent
b73865ddae
commit
78a054f0a1
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { useEffect } from 'preact/hooks'
|
||||||
|
|
||||||
|
export function useTitle(title: string) {
|
||||||
|
useEffect(() => {
|
||||||
|
document.title = `${title} | Orion Reed`
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import { Header } from '@/components/Header'
|
import { Header } from '@/components/Header'
|
||||||
|
import { useTitle } from '@/hooks/useTitle'
|
||||||
import { Container, Text, Title, Anchor, Space } from '@mantine/core'
|
import { Container, Text, Title, Anchor, Space } from '@mantine/core'
|
||||||
|
|
||||||
export function Home() {
|
export function Home() {
|
||||||
|
useTitle('Home')
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,19 @@ import {
|
||||||
createStyles,
|
createStyles,
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import { friendlyDate, getJsonl } from '@/utils'
|
import { friendlyDate, getJsonl } from '@/utils'
|
||||||
|
import { useTitle } from '@/hooks/useTitle'
|
||||||
|
|
||||||
const posts = await getJsonl('/posts.jsonl')
|
const posts = await getJsonl('/posts.jsonl')
|
||||||
|
|
||||||
type Post = {
|
|
||||||
slug: string
|
|
||||||
title: string
|
|
||||||
date: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
index: {
|
index: {
|
||||||
fontFamily: theme.fontFamilyMonospace,
|
fontFamily: theme.fontFamilyMonospace,
|
||||||
fontSize: '0.85em',
|
fontSize: '0.75em',
|
||||||
alignSelf: 'flex-end',
|
alignSelf: 'flex-end',
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
fontFamily: theme.fontFamilyMonospace,
|
fontFamily: theme.fontFamilyMonospace,
|
||||||
fontSize: '0.85em',
|
fontSize: '0.75em',
|
||||||
alignSelf: 'flex-end',
|
alignSelf: 'flex-end',
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
@ -39,11 +34,11 @@ function PostListItem({ slug, title, date, index }) {
|
||||||
<Text color="dimmed" className={classes.index}>
|
<Text color="dimmed" className={classes.index}>
|
||||||
{`${index}`.padStart(3, '0')}
|
{`${index}`.padStart(3, '0')}
|
||||||
</Text>
|
</Text>
|
||||||
<Anchor href={`posts/${slug}`} color={black}>
|
<Anchor href={`posts/${slug}`} td="none" color={black}>
|
||||||
{title}
|
{title}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
<Text color="dimmed" fs="italic" className={classes.date}>
|
<Text color="dimmed" fs="italic" className={classes.date}>
|
||||||
{friendlyDate(date, 'dd/MMM/yyyy')}
|
{friendlyDate(date, 'MMM dd')}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
|
|
@ -62,6 +57,7 @@ function Frame({ children }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Posts() {
|
export function Posts() {
|
||||||
|
useTitle('Posts')
|
||||||
return (
|
return (
|
||||||
<Frame>
|
<Frame>
|
||||||
{posts.map((post, index, array) => {
|
{posts.map((post, index, array) => {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import Markdown from 'markdown-to-jsx'
|
||||||
import MiniSearch from 'minisearch'
|
import MiniSearch from 'minisearch'
|
||||||
import { signal } from '@preact/signals'
|
import { signal } from '@preact/signals'
|
||||||
import { friendlyDate, getJsonl } from '@/utils'
|
import { friendlyDate, getJsonl } from '@/utils'
|
||||||
|
import { useTitle } from '@/hooks/useTitle'
|
||||||
|
|
||||||
const search = signal('')
|
const search = signal('')
|
||||||
|
|
||||||
|
|
@ -129,8 +130,12 @@ function Search() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Stream() {
|
export default function Stream() {
|
||||||
|
useTitle('Stream')
|
||||||
const { classes } = useStyles()
|
const { classes } = useStyles()
|
||||||
const results = !search.value ? streamItems : miniSearch.search(search.value)
|
const results = !search.value ? streamItems : miniSearch.search(search.value)
|
||||||
|
console.log(search.value)
|
||||||
|
console.log(results)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header />
|
<Header />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue