mirror of
https://github.com/quartz-community/breadcrumbs.git
synced 2026-07-22 02:50:29 +00:00
refactor: use shared classNames from @quartz-community/utils
This commit is contained in:
parent
aa269f5cce
commit
205713950c
2 changed files with 5 additions and 27 deletions
|
|
@ -1,3 +1 @@
|
|||
export function classNames(...classes: (string | undefined | null | false)[]): string {
|
||||
return classes.filter(Boolean).join(" ");
|
||||
}
|
||||
export { classNames } from "@quartz-community/utils/lang";
|
||||
|
|
|
|||
|
|
@ -1,26 +1,6 @@
|
|||
import { simplifySlug as utilSimplifySlug, joinSegments } from "@quartz-community/utils";
|
||||
|
||||
export function simplifySlug(fp: string): string {
|
||||
return utilSimplifySlug(fp);
|
||||
declare module "@quartz-community/utils/path" {
|
||||
export function simplifySlug(fp: string): string;
|
||||
export function resolveRelative(current: string, target: string): string;
|
||||
}
|
||||
|
||||
export function resolveRelative(current: string, target: string): string {
|
||||
const simplified = simplifySlug(target);
|
||||
const rootPath = pathToRoot(current);
|
||||
return joinSegments(rootPath, simplified);
|
||||
}
|
||||
|
||||
function pathToRoot(slug: string): string {
|
||||
let rootPath = slug
|
||||
.split("/")
|
||||
.filter((x) => x !== "")
|
||||
.slice(0, -1)
|
||||
.map((_) => "..")
|
||||
.join("/");
|
||||
|
||||
if (rootPath.length === 0) {
|
||||
rootPath = ".";
|
||||
}
|
||||
|
||||
return rootPath;
|
||||
}
|
||||
export { simplifySlug, resolveRelative } from "@quartz-community/utils/path";
|
||||
|
|
|
|||
Loading…
Reference in a new issue