/
superded
/
void
Обзор
Документация
Войти
/
superded
/
void
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
readme
quartz/util/path.ts
52 строки
1 KB
superded42
Initial commit
04 июл 2026, 05:05
Не верифицирован
04 июл 2026, 05:05
af1cbe5
Код
Авторство
О чём код?
// Re-export shared path utilities from @quartz-community/utils export { isFilePath, isFullSlug, isSimpleSlug, isRelativeURL, isAbsoluteURL, getFullSlug, slugifyFilePath, simplifySlug, joinSegments, endsWith, trimSuffix, stripSlashes, getFileExtension, isFolderPath, getAllSegmentPrefixes, pathToRoot, resolveRelative, splitAnchor, slugTag, transformInternalLink, transformLink, normalizeHastElement, } from "@quartz-community/utils" export type { FilePath, FullSlug, SimpleSlug, RelativeURL, TransformOptions, } from "@quartz-community/utils" // --- v5-specific exports below --- export const QUARTZ = "quartz" // from micromorph/src/utils.ts // https://github.com/natemoo-re/micromorph/blob/main/src/utils.ts#L5 const _rebaseHtmlElement = (el: Element, attr: string, newBase: string | URL) => { const rebased = new URL(el.getAttribute(attr)!, newBase) el.setAttribute(attr, rebased.pathname + rebased.hash) } export function normalizeRelativeURLs(el: Element | Document, destination: string | URL) { el.querySelectorAll('[href=""], [href^="./"], [href^="../"]').forEach((item) => { _rebaseHtmlElement(item, "href", destination) }) el.querySelectorAll('[src=""], [src^="./"], [src^="../"]').forEach((item) => { _rebaseHtmlElement(item, "src", destination) }) }