mirror of
https://github.com/quartz-community/utils.git
synced 2026-07-22 02:50:27 +00:00
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:
parent
bb5c136296
commit
83f824b0ad
4 changed files with 22 additions and 1 deletions
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
|
|
@ -15,6 +15,7 @@ export {
|
|||
isRelativeURL,
|
||||
isSimpleSlug,
|
||||
joinSegments,
|
||||
normalizeHastElement,
|
||||
pathToRoot,
|
||||
resolveBasePath,
|
||||
resolvePath,
|
||||
|
|
|
|||
19
dist/index.js
vendored
19
dist/index.js
vendored
|
|
@ -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
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -25,6 +25,7 @@ export {
|
|||
slugTag,
|
||||
transformInternalLink,
|
||||
transformLink,
|
||||
normalizeHastElement,
|
||||
} from "./path.js";
|
||||
|
||||
export type { FilePath, FullSlug, SimpleSlug, RelativeURL, TransformOptions } from "./path.js";
|
||||
|
|
|
|||
Loading…
Reference in a new issue