Commit graph

30 commits

Author SHA1 Message Date
saberzero1
2f2f5da516
fix: block links resolution casing issues 2026-05-26 17:44:32 +02:00
saberzero1
7a43501ac1
build: rebuild dist with transformInternalLink folder-path fix 2026-04-22 18:13:20 +02:00
saberzero1
6721918708
fix(path): detect folder paths after slugification in transformInternalLink
isFolderPath() was checked on the raw input before slugifyFilePath()
rewrote folder notes (e.g. "My Folder/My Folder" -> "my-folder/index").
Now checks isFolderPath on both the raw input and the slugified result,
so the trailing slash is correctly emitted for folder note links.
2026-04-22 18:13:15 +02:00
saberzero1
83f824b0ad
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.
2026-04-17 02:26:31 +02:00
saberzero1
bb5c136296
feat(path): add normalizeHastElement for cross-slug HAST rebasing
Moved from Quartz core (quartz/util/path.ts) into the shared utils
package so that plugins performing cross-slug HAST embedding can
re-use the same rebase helper as Quartz's internal transclude
expansion, rather than reimplementing or skipping the rebase.

The primary consumer outside of Quartz core is canvas-page, whose
buildEmbeddedContent() pulls vfile.data.htmlAst from arbitrary target
pages and serializes it verbatim into canvas pages - producing broken
relative hrefs that survive accidentally on root deployments but fail
under non-trivial basePath configurations. Exposing the helper here
lets canvas-page (and any future embedding plugin) rebase correctly
without duplicating the logic.

Implementation details:
- Deep-clones the input via structuredClone (Node >=22 builtin) so
  callers don't need to bring their own clone function
- Absolute URLs (http://, https://, /root-relative) pass through
  untouched; only relative URLs are rebased
- Recurses into children so nested anchors inside a rebased subtree
  are also normalized

Backed by 10 new tests covering same-slug, cross-slug (both directions),
nested depth, anchor preservation, absolute URL passthrough, root-relative
passthrough, src-attribute rebasing, elements without href/src, nested
children recursion, and input-immutability.
2026-04-17 02:24:33 +02:00
saberzero1
4dda81bc82
feat(path)!: lowercase slugs for Obsidian-parity case-insensitive matching
slugifyPath now lowercases its output, which cascades through
slugifyFilePath, slugTag, and transformInternalLink (all of which
funnel through _sluggify).

This matches Obsidian's case-insensitive link and tag matching:
[[MyNote]], [[mynote]], and [[MYNOTE]] all resolve to the slug
'my-note', and the tags #MyTag, #mytag, and #MYTAG collapse into a
single tag page.

BREAKING CHANGE: all generated URLs are now lowercase. Users
upgrading with mixed-case source filenames will see their URLs
change (e.g. /MyNote -> /my-note). Also eliminates silent data
loss on case-insensitive filesystems (macOS APFS, Windows NTFS)
where Apple.md and apple.md previously produced conflicting HTML
outputs that overwrote each other without warning.
2026-04-16 21:12:37 +02:00
saberzero1
e17fc8d5f0
feat(path): support folder note convention 2026-04-10 19:16:30 +02:00
saberzero1
cf1450b6f7
fix: safely handle undefined getDate in byDateAndAlphabetical 2026-04-03 15:58:13 +02:00
saberzero1
fbc9d6e9cb
fix: return undefined instead of throwing when defaultDateType is not set 2026-04-03 15:53:17 +02:00
saberzero1
20b1ac1844
feat: add getDate and byDateAndAlphabetical sort utilities 2026-04-03 15:39:35 +02:00
saberzero1
8b6e32ba07
feat: add formatDate and getIconCode utility exports 2026-04-03 15:04:35 +02:00
saberzero1
ef25479647
fix: move tsconfig from dts object to top-level option
The DtsConfig type in tsup does not have a tsconfig property.
Use top-level tsconfig option instead of dts: { tsconfig: ... }.
2026-03-22 13:25:13 +01:00
saberzero1
35f458e9d2
fix: use separate tsconfig for DTS build to avoid vitest dependency 2026-03-22 13:12:01 +01:00
saberzero1
8d2e14bcb9
build: rebuild dist with multi-segment path fix 2026-03-22 12:20:49 +01:00
saberzero1
1ad4e4f2f6
fix: support multi-segment partial paths in shortest link resolution
The 'shortest' strategy in transformLink() only matched by filename (last
segment), causing wiki-links like [[Species/Elf/Wood]] to fail resolution
when the target lived under a deeper path (e.g. Compendium/Species/Elf/Wood).

Add suffix-based matching for multi-segment partial paths and handle the
/index variant for folder targets whose suffix gets stripped by
transformInternalLink().
2026-03-22 11:51:41 +01:00
saberzero1
1bc315eb6e
fix: handle folder/index page slugs in transformLink relative path computation
When src is a folder page (e.g. 'Compendium/Spells' backed by index.md),
pathToRoot miscalculated the depth because the browser serves folder pages
at '/Compendium/Spells/' (trailing slash). Now detects folder pages via
allSlugs and uses the index slug for correct relative URL generation.
2026-03-20 11:45:06 +01:00
saberzero1
e0b3f658b9
feat: export slugifyPath as public utility 2026-03-20 11:19:40 +01:00
saberzero1
d7d93758b2
feat: add getBasePath and resolveBasePath for subdirectory deployments
Add utility functions to resolve links correctly when Quartz is deployed
to a subdirectory (e.g., user.github.io/repository). getBasePath() reads
the base path from a data attribute on <body>, and resolveBasePath()
prepends it to slugs for client-side navigation.
2026-03-18 11:50:30 +01:00
saberzero1
81189f697c
chore: commit dist/ and remove prepare script
With build tools (tsup, typescript) moved to devDependencies, the prepare
script can no longer build when npm fetches this package from GitHub (npm
does not install devDependencies for git dependencies). Commit the pre-built
dist/ output so GitHub-based installs work without a build step.
2026-03-14 21:30:17 +01:00
saberzero1
61cbfb9807
chore: move build tools to devDependencies, shared deps to peerDependencies
tsup and typescript are only needed at build time — move to devDependencies
so they can be pruned after build. hast-util-to-jsx-runtime and github-slugger
are available from the host Quartz installation — move to peerDependencies
to avoid duplication across 42+ plugins.
2026-03-14 21:26:13 +01:00
saberzero1
98ee433a93
feat: add htmlToJsx wrapper for safe HAST-to-JSX rendering
Provides a wrapped toJsxRuntime that prevents HTML-escaping of <style>
and <script> content by using dangerouslySetInnerHTML overrides.
Exported as @quartz-community/utils/jsx entry point.
2026-03-08 19:25:27 +01:00
saberzero1
c4e9381a9d
deps: update @quartz-community/types 2026-02-28 20:08:37 +01:00
saberzero1
eaa6160504
fix: move tsup and typescript to dependencies for git install compatibility
When installed as a git dependency, npm skips devDependencies. Since
dist/ is gitignored and the prepare script needs tsup to build, these
must be regular dependencies so the prepare hook works on install.
2026-02-22 22:05:35 +01:00
saberzero1
15d75b89e1
fix: use FullSlug/FilePath types from @quartz-community/types for type compatibility
Import branded types from the canonical types package instead of
re-defining them with different brand names. This ensures plugins
using both @quartz-community/types and @quartz-community/utils
have structurally compatible FullSlug and FilePath types.
2026-02-13 22:28:05 +01:00
saberzero1
d4a5e3b97d
feat: add path utilities, escape helpers, and capitalize for transformer plugins
Add splitAnchor, transformLink, transformInternalLink, resolveRelative,
pathToRoot, slugifyFilePath, slugTag, FilePath type, and various type
guards to path.ts. Add escapeHTML/unescapeHTML in new escape.ts module.
Add capitalize to lang.ts. Add github-slugger dependency.
2026-02-13 22:24:41 +01:00
saberzero1
cf3e0a386a
fix: active class 2026-02-09 22:38:41 +01:00
saberzero1
c5aea2d0e9
fix: event listeners 2026-02-09 21:22:00 +01:00
saberzero1
9520e0dcf9
fix: event listeners 2026-02-09 21:07:41 +01:00
saberzero1
61970ce89f
feat: migrate to shared utility library
- Remove plugin template code
- Add path utilities (simplifySlug, joinSegments, etc.)
- Add DOM utilities (removeAllChildren, registerEscapeHandler)
- Add lang utilities (classNames)
- Update package.json for @quartz-community/utils
- Add tests for path utilities
2026-02-09 12:38:53 +01:00
Emile Bangma
09c5a21ea0
Initial commit 2026-02-09 12:28:32 +01:00