public_notes/quartz/components/PageTitle.tsx

23 lines
663 B
TypeScript
Raw Normal View History

import { pathToRoot } from "../util/path"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { classNames } from "../util/lang"
import { i18n } from "../i18n"
2023-06-08 14:27:32 +09:00
const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
const baseDir = pathToRoot(fileData.slug!)
2023-07-23 09:27:41 +09:00
return (
<h1 class={classNames(displayClass, "page-title")}>
2023-07-23 09:27:41 +09:00
<a href={baseDir}>{title}</a>
</h1>
)
2023-06-08 14:27:32 +09:00
}
2023-06-12 15:46:38 +09:00
2023-07-02 05:35:27 +09:00
PageTitle.css = `
.page-title {
margin: 0;
}
`
2023-06-19 02:47:07 +09:00
2023-07-02 05:35:27 +09:00
export default (() => PageTitle) satisfies QuartzComponentConstructor