From a53772bbd1dd2804872ae0e519bedeb2a2fd4287 Mon Sep 17 00:00:00 2001
From: Osman Tunahan ARIKAN <154083945+OsmanTunahan@users.noreply.github.com>
Date: Wed, 30 Oct 2024 22:33:22 +0000
Subject: [PATCH] feat(i18n): add turkish language (#1554)
---
quartz/components/Breadcrumbs.tsx | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/quartz/components/Breadcrumbs.tsx b/quartz/components/Breadcrumbs.tsx
index eab8a34..9ccfb9a 100644
--- a/quartz/components/Breadcrumbs.tsx
+++ b/quartz/components/Breadcrumbs.tsx
@@ -1,6 +1,6 @@
-import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
+import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import breadcrumbsStyle from "./styles/breadcrumbs.scss"
-import { FullSlug, SimpleSlug, resolveRelative } from "../util/path"
+import { FullSlug, SimpleSlug, joinSegments, resolveRelative } from "../util/path"
import { QuartzPluginData } from "../plugins/vfile"
import { classNames } from "../util/lang"
@@ -54,7 +54,11 @@
// computed index of folder name to its associated file data
let folderIndex: Map<string, QuartzPluginData> | undefined
- function Breadcrumbs({ fileData, allFiles, displayClass }: QuartzComponentProps) {
+ const Breadcrumbs: QuartzComponent = ({
+ fileData,
+ allFiles,
+ displayClass,
+ }: QuartzComponentProps) => {
// Hide crumbs on root if enabled
if (options.hideOnRoot && fileData.slug === "index") {
return <></>
@@ -78,8 +82,12 @@
// Split slug into hierarchy/parts
const slugParts = fileData.slug?.split("/")
if (slugParts) {
+ // is tag breadcrumb?
+ const isTagPath = slugParts[0] === "tags"
+
// full path until current part
let currentPath = ""
+
for (let i = 0; i < slugParts.length - 1; i++) {
let curPathSegment = slugParts[i]
@@ -93,10 +101,15 @@
}
// Add current slug to full path
- currentPath += slugParts[i] + "/"
+ currentPath = joinSegments(currentPath, slugParts[i])
+ const includeTrailingSlash = !isTagPath || i < 1
// Format and add current crumb
- const crumb = formatCrumb(curPathSegment, fileData.slug!, currentPath as SimpleSlug)
+ const crumb = formatCrumb(
+ curPathSegment,
+ fileData.slug!,
+ (currentPath + (includeTrailingSlash ? "/" : "")) as SimpleSlug,
+ )
crumbs.push(crumb)
}
@@ -121,5 +134,6 @@
)
}
Breadcrumbs.css = breadcrumbsStyle
+
return Breadcrumbs
}) satisfies QuartzComponentConstructor
--
Gitblit v1.10.0