mirror of
https://github.com/10h30/astroplate.git
synced 2026-06-05 15:08:00 +09:00
breadcrumbs && jsonGenerator updated
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
---
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import config from "@/config/config.json";
|
||||
|
||||
const { supported } = config.language;
|
||||
|
||||
const { className }: { className?: string } = Astro.props;
|
||||
|
||||
const paths = Astro.url.pathname.split("/").filter((x) => x);
|
||||
|
||||
let lang = "";
|
||||
if (supported.includes(paths[0])) {
|
||||
lang = paths.shift()!;
|
||||
}
|
||||
|
||||
let parts = [
|
||||
{
|
||||
label: "Home",
|
||||
href: "/",
|
||||
"aria-label": Astro.url.pathname === "/" ? "page" : undefined,
|
||||
href: `/${lang}`,
|
||||
"aria-label": Astro.url.pathname === `/${lang}` || Astro.url.pathname === `/${lang}/` ? "page" : undefined,
|
||||
},
|
||||
];
|
||||
|
||||
paths.forEach((label: string, i: number) => {
|
||||
const href = `/${paths.slice(0, i + 1).join("/")}`;
|
||||
const href = `/${lang}/${paths.slice(0, i + 1).join("/")}`;
|
||||
label !== "page" &&
|
||||
parts.push({
|
||||
label: humanize(label.replace(".html", "").replace(/[-_]/g, " ")) || "",
|
||||
@@ -21,6 +30,7 @@ paths.forEach((label: string, i: number) => {
|
||||
"aria-label": Astro.url.pathname === href ? "page" : undefined,
|
||||
});
|
||||
});
|
||||
|
||||
---
|
||||
|
||||
<nav aria-label="Breadcrumb" class={className}>
|
||||
@@ -28,7 +38,7 @@ paths.forEach((label: string, i: number) => {
|
||||
{
|
||||
parts.map(({ label, ...attrs }, index) => (
|
||||
<li class="mx-1 capitalize" role="listitem">
|
||||
{index > 0 && <span class="inlin-block mr-1">/</span>}
|
||||
{index > 0 && <span class="inline-block mr-1">/</span>}
|
||||
{index !== parts.length - 1 ? (
|
||||
<a class="text-primary dark:text-darkmode-primary" {...attrs}>
|
||||
{label}
|
||||
|
||||
Reference in New Issue
Block a user