rizaldy.club/quartz/components/PageTitle.tsx

23 lines
626 B
TypeScript
Raw Normal View History

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