Files
pubky-knowledge-base/quartz/quartz/components/PageTitle.tsx
flaviomoceri 34cdab453e new UI WIP
2024-10-21 14:20:21 +02:00

31 lines
812 B
TypeScript

import { pathToRoot } from "../util/path"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { classNames } from "../util/lang"
import { i18n } from "../i18n"
const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzComponentProps) => {
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
const baseDir = pathToRoot(fileData.slug!)
return (
<h2 class={classNames(displayClass, "page-title")}>
<a href={baseDir}>
{title === "Pubky Knowledge Base" && (
<>
Pubky
<br />
Knowledge Base
</>
)}
</a>
</h2>
)
}
PageTitle.css = `
.page-title {
margin: 0;
}
`
export default (() => PageTitle) satisfies QuartzComponentConstructor