2023-08-19 22:52:25 +00:00
|
|
|
import { pathToRoot } from "../util/path"
|
2024-02-14 04:53:44 +00:00
|
|
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
2024-01-30 05:51:13 +00:00
|
|
|
import { classNames } from "../util/lang"
|
2024-02-05 04:57:10 +00:00
|
|
|
import { i18n } from "../i18n"
|
2023-06-08 05:27:32 +00:00
|
|
|
|
2024-02-14 04:53:44 +00:00
|
|
|
const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {
|
2024-02-05 04:57:10 +00:00
|
|
|
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
2023-08-19 22:52:25 +00:00
|
|
|
const baseDir = pathToRoot(fileData.slug!)
|
2023-07-23 00:27:41 +00:00
|
|
|
return (
|
2024-01-30 05:51:13 +00:00
|
|
|
<h1 class={classNames(displayClass, "page-title")}>
|
2023-07-23 00:27:41 +00:00
|
|
|
<a href={baseDir}>{title}</a>
|
|
|
|
</h1>
|
|
|
|
)
|
2023-06-08 05:27:32 +00:00
|
|
|
}
|
2023-06-12 06:46:38 +00:00
|
|
|
|
2023-07-01 20:35:27 +00:00
|
|
|
PageTitle.css = `
|
|
|
|
.page-title {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
`
|
2023-06-18 17:47:07 +00:00
|
|
|
|
2023-07-01 20:35:27 +00:00
|
|
|
export default (() => PageTitle) satisfies QuartzComponentConstructor
|