fix(path): re-export normalizeHastElement from index

The initial commit added normalizeHastElement to src/path.ts but
forgot to include it in src/index.ts's top-level re-export list,
so importers doing `import { normalizeHastElement } from '@quartz-community/utils'`
would see 'has no exported member'. Imports via the /path subpath
worked, but the top-level entrypoint is the conventional import
surface for most consumers.
This commit is contained in:
saberzero1 2026-04-17 02:26:31 +02:00
parent bb5c136296
commit 83f824b0ad
No known key found for this signature in database
4 changed files with 22 additions and 1 deletions

1
dist/index.d.ts vendored
View file

@ -15,6 +15,7 @@ export {
isRelativeURL,
isSimpleSlug,
joinSegments,
normalizeHastElement,
pathToRoot,
resolveBasePath,
resolvePath,

19
dist/index.js vendored
View file

@ -222,6 +222,24 @@ function slugifyPath(s) {
.join("/")
.replace(/\/$/, "");
}
function normalizeHastElement(rawEl, curBase, newBase) {
const el = structuredClone(rawEl);
_rebaseHastElement(el, "src", curBase, newBase);
_rebaseHastElement(el, "href", curBase, newBase);
if (el.children) {
el.children = el.children.map((child) =>
child.type === "element" ? normalizeHastElement(child, curBase, newBase) : child,
);
}
return el;
}
function _rebaseHastElement(el, attr, curBase, newBase) {
const value = el.properties?.[attr];
if (value === void 0 || value === null) return;
const href = String(value);
if (!isRelativeURL(href)) return;
el.properties[attr] = joinSegments(resolveRelative(curBase, newBase), "..", href);
}
function _sluggify(s) {
return slugifyPath(s);
}
@ -437,6 +455,7 @@ export {
isRelativeURL,
isSimpleSlug,
joinSegments,
normalizeHastElement,
normalizeRelativeURLs,
pathToRoot,
registerEscapeHandler,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -25,6 +25,7 @@ export {
slugTag,
transformInternalLink,
transformLink,
normalizeHastElement,
} from "./path.js";
export type { FilePath, FullSlug, SimpleSlug, RelativeURL, TransformOptions } from "./path.js";