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