mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-02-04 06:25:41 -06:00
localize breadcrubs rootName
This commit is contained in:
parent
25a6747d7d
commit
be1cb3e350
@ -3,6 +3,7 @@ import breadcrumbsStyle from "./styles/breadcrumbs.scss"
|
||||
import { FullSlug, SimpleSlug, resolveRelative, simplifySlug } from "../util/path"
|
||||
import { classNames } from "../util/lang"
|
||||
import { trieFromAllFiles } from "../util/ctx"
|
||||
import { i18n } from "../i18n"
|
||||
|
||||
type CrumbData = {
|
||||
displayName: string
|
||||
@ -30,7 +31,7 @@ interface BreadcrumbOptions {
|
||||
|
||||
const defaultOptions: BreadcrumbOptions = {
|
||||
spacerSymbol: "❯",
|
||||
rootName: "Home",
|
||||
rootName: "",
|
||||
resolveFrontmatterTitle: true,
|
||||
showCurrentPage: true,
|
||||
}
|
||||
@ -49,6 +50,7 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
||||
allFiles,
|
||||
displayClass,
|
||||
ctx,
|
||||
cfg,
|
||||
}: QuartzComponentProps) => {
|
||||
const trie = (ctx.trie ??= trieFromAllFiles(allFiles))
|
||||
const slugParts = fileData.slug!.split("/")
|
||||
@ -61,7 +63,7 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
||||
const crumbs: CrumbData[] = pathNodes.map((node, idx) => {
|
||||
const crumb = formatCrumb(node.displayName, fileData.slug!, simplifySlug(node.slug))
|
||||
if (idx === 0) {
|
||||
crumb.displayName = options.rootName
|
||||
crumb.displayName = options.rootName !== "" ? options.rootName : i18n(cfg.locale).components.breadcrumbs.rootName;
|
||||
}
|
||||
|
||||
// For last node (current page), set empty path
|
||||
|
||||
@ -62,6 +62,9 @@ export interface Translation {
|
||||
contentMeta: {
|
||||
readingTime: (variables: { minutes: number }) => string
|
||||
}
|
||||
breadcrumbs: {
|
||||
rootName: string
|
||||
}
|
||||
}
|
||||
pages: {
|
||||
rss: {
|
||||
|
||||
@ -59,6 +59,9 @@ export default {
|
||||
contentMeta: {
|
||||
readingTime: ({ minutes }) => `${minutes} min read`,
|
||||
},
|
||||
breadcrumbs: {
|
||||
rootName: "Home"
|
||||
},
|
||||
},
|
||||
pages: {
|
||||
rss: {
|
||||
|
||||
@ -59,6 +59,9 @@ export default {
|
||||
contentMeta: {
|
||||
readingTime: ({ minutes }) => `${minutes} min read`,
|
||||
},
|
||||
breadcrumbs: {
|
||||
rootName: "Home"
|
||||
},
|
||||
},
|
||||
pages: {
|
||||
rss: {
|
||||
|
||||
@ -59,6 +59,9 @@ export default {
|
||||
contentMeta: {
|
||||
readingTime: ({ minutes }) => `${minutes} perces olvasás`,
|
||||
},
|
||||
breadcrumbs: {
|
||||
rootName: "Otthon"
|
||||
},
|
||||
},
|
||||
pages: {
|
||||
rss: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user