2023-06-08 12:27:32 +07:00
|
|
|
import { resolveToRoot } from "../path"
|
2023-06-12 13:46:38 +07:00
|
|
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
2023-06-08 12:27:32 +07:00
|
|
|
|
2023-06-19 00:47:07 +07:00
|
|
|
interface Options {
|
|
|
|
title: string
|
2023-06-08 12:27:32 +07:00
|
|
|
}
|
2023-06-12 13:46:38 +07:00
|
|
|
|
2023-06-19 00:47:07 +07:00
|
|
|
export default ((opts?: Options) => {
|
|
|
|
const title = opts?.title ?? "Untitled Quartz"
|
|
|
|
function PageTitle({ fileData }: QuartzComponentProps) {
|
|
|
|
const slug = fileData.slug!
|
|
|
|
const baseDir = resolveToRoot(slug)
|
|
|
|
return <h1 class="page-title"><a href={baseDir}>{title}</a></h1>
|
|
|
|
}
|
|
|
|
PageTitle.css = `
|
|
|
|
.page-title {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
return PageTitle
|
|
|
|
}) satisfies QuartzComponentConstructor
|