wiki/quartz/components/Backlinks.tsx
Aaron Pham 37c6231e79
fix(div): update class name to remove weird space afterwards (#763)
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
2024-01-29 21:51:13 -08:00

30 lines
995 B
TypeScript

import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
import style from "./styles/backlinks.scss"
import { resolveRelative, simplifySlug } from "../util/path"
import { classNames } from "../util/lang"
function Backlinks({ fileData, allFiles, displayClass }: QuartzComponentProps) {
const slug = simplifySlug(fileData.slug!)
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
return (
<div class={classNames(displayClass, "backlinks")}>
<h3>Backlinks</h3>
<ul class="overflow">
{backlinkFiles.length > 0 ? (
backlinkFiles.map((f) => (
<li>
<a href={resolveRelative(fileData.slug!, f.slug!)} class="internal">
{f.frontmatter?.title}
</a>
</li>
))
) : (
<li>No backlinks found</li>
)}
</ul>
</div>
)
}
Backlinks.css = style
export default (() => Backlinks) satisfies QuartzComponentConstructor