No description
Find a file
Sara Lilith Slootmaker 74a8afcf1f
Quartz community main (#14)
* Port to Quartz v5 Bases view plugin

Rewrite the v4 transformer plugin as a v5 Bases view plugin that
registers a 'leaflet-map' view type via the bases-page view registry.

- Add v5 plugin structure: package.json, tsup.config.ts, tsconfig.json
- Add view renderer (src/view.tsx) that builds server-side marker HTML
- Add client-side Leaflet initialization (src/scripts/leaflet-map.inline.ts)
- Add full Leaflet + custom marker styles (src/styles/leaflet-map.scss)
- Add type definitions for view config and marker data (src/types.ts)
- Auto-register view on import via viewRegistry.register()
- Mark @quartz-community/bases-page as external peer dependency
- ESM + DTS build via tsup with inline-script and SCSS loaders

* fix: move bases-page from dependencies to devDependencies

bases-page must only be a peerDependency at runtime so Node resolves
to the host's installed copy. Keeping it as a regular dependency caused
npm to install a private copy in node_modules/, creating a separate
ViewRegistry instance that never communicated with the host plugin.

Now bases-page is a devDependency (needed for TypeScript compilation)
and a peerDependency (resolved at runtime from the host).

* feat: resolve image paths via transformLink for correct link resolution

- Import transformLink and FullSlug from @quartz-community/bases-page
- Use slug, allSlugs, linkResolution props from ViewRendererProps
- Remove stale ambient module declaration that shadowed real package types
- Add @quartz-community/utils and @quartz-community/types as devDependencies

* fix: defer ControlContainer class definition to avoid L is not defined at parse time

* fix: add CDN fallback and error handling for dependency loading

Switch primary CDN from unpkg.com to cdn.jsdelivr.net with unpkg.com as
fallback. Add loadScript() helper that tries multiple URLs sequentially.
Add try/catch around loadDependencies() in the nav listener with early
return when no map elements found, and user-visible error message when
all CDN sources fail. Fixes maps not loading when browser content
blocking (e.g. Firefox Enhanced Tracking Protection) blocks unpkg.com.

* chore: linting

* feat: add render event listener for in-place DOM re-initialization

* fix: update to bases-page changes

* feat: allow plugin views to pass options

* Cleanup typing

* Remove quartz v4plugin files

* Removal of duplicated imports

* Cleanup typing

* Removal of duplicated imports

* chore: commit dist/ and remove prepare script

* Update README.md

* fix: update to bases-page changes

* chore: rebase

* Cleanup typing

* Removal of duplicated imports

* Cleanup typing

* Remove quartz v4plugin files

* Removal of duplicated imports

---------

Co-authored-by: saberzero1 <github@emilebangma.com>
2026-03-16 16:41:50 +00:00
.github/workflows Fix it again 2026-02-24 20:44:27 +01:00
dist Quartz community main (#14) 2026-03-16 16:41:50 +00:00
docs Finishing touches 2025-07-10 12:57:22 +02:00
src Quartz community main (#14) 2026-03-16 16:41:50 +00:00
.eslintrc.json Quartz community main (#14) 2026-03-16 16:41:50 +00:00
.gitignore chore: commit dist/ and remove prepare script 2026-03-16 12:01:24 +01:00
.prettierignore Finishing touches 2025-07-10 12:57:22 +02:00
.prettierrc chore: linting 2026-03-12 12:27:51 +01:00
LICENSE.txt Small fixes 2025-07-10 10:56:42 +02:00
package-lock.json Quartz community main (#14) 2026-03-16 16:41:50 +00:00
package.json Quartz community main (#14) 2026-03-16 16:41:50 +00:00
README.md Quartz community main (#14) 2026-03-16 16:41:50 +00:00
tsconfig.json chore: linting 2026-03-12 12:27:51 +01:00
tsup.config.ts chore: linting 2026-03-12 12:27:51 +01:00

Quarts Leaflet Bases Plugin

This the the Quartz counterpart of the Obsidian Leaflet Bases plugin. This plugin adds a custom leaflet map implementation for websites build using Quartz.

Demo

A live demo can be found here and its source here.

How to add it to your quartz

Quartz v5

Add the plugin to the plugins list in your quartz.config.yaml:

plugins:
    - source: github:quartz-community/external-quartz-leaflet-map-plugin
      enabled: true

This plugin also requires the bases-page plugin.

Plugin Options

You can pass options to the plugin via quartz.config.yaml:

plugins:
    - source: github:quartz-community/external-quartz-leaflet-map-plugin
      enabled: true
      options:
          enableCopyTool: true
Option Type Default Description
enableCopyTool boolean false Enables the copy tool from the Obsidian Leaflet Bases plugin.

Quartz v4

Quartz v4 does not have a bases implementation. As such it is highly recommended (read 'basically required') to use the mapName feature if your vault has multiple maps.

Ensure you have a release tagged for Quartz v4

  • Add file leafletMapPlugin.ts to your quartz\plugins\transformers\
  • Append line export { LeafletMap } from "./leafletMapPlugin" to your quartz\plugins\transformers\index.ts
  • Place line Plugin.LeafletMap(), to your quartz.config.ts in the end of plugins: { transformers: section
    • Optional: To enable the copy tool from the Obsidian plugin, add Plugin.LeafletMap({ enableCopyTool: true }), instead

How to use

How to add a map to a note

Adding a map to a note is done by adding the following block of code to where you want the map to appear.

```base
views:
  - type: leaflet-map
    name: Map
    mapName: test
    image: assets/Locke.png
    height: 400
    minZoom: -1.5
    maxZoom: 2
    defaultZoom: -1.5
    zoomDelta: 0.25
    scale: "0.2"
    unit: km
```
Setting What it does
type The type of base, don't change this (from Obsidian bases)
name What the view is called (from Obsidian bases)
image The image the map should show. It also accepts wiki links. Can be any image supported by Quartz
mapName Optional identifier for the map. Useful if you want to reuse a note across several maps
defaultZoom The zoom value the map opens with. Defaults to minZoom
minZoom How far you can zoom out. Defaults to 0. This value is allowed to be a decimal number and can be negative
maxZoom How far you can zoom in. Defaults to 2. This value is allowed to be a decimal number and can be negative
zoomDelta How granular zooming is. This value is allowed to be a decimal number.
scale How much to scale the result of the measure tool. This value is allowed to be a decimal number
unit The unit the measure tool uses (think km, mi, hours)

Technically only type, name, and image are required for the map view to work. However you'll likely end up using most of the other settings.

In v4 only image is required for the map view to work.

  • mapName can be replaced by how you'd like to call your map. You should remember this value as we'll need it to add markers to you map later on. The map name does not need to be unique, but be sure the images are either identical or compatible for marker placement.
  • minZoom, maxZoom are optional boundaries on how much you'll be able to zoom the map. Depending on your map image you might need to fiddle with these, or remove them altogether since they are optional.

How to add a marker to a map

Adding a marker to a map is done by adding the following block of code to the frontmatter of the note you'd want the marker to link to. The example adds two markers.

---
marker:
    - coordinates: 100, 300
      icon: lucide-tree-pine
      colour: "#039c4b"
      minZoom: 1
    - coordinates: 5, 5
      mapName: mapName
      colour: "#bdf123"
---
Setting What it does
Map name mapName If you want this marker to only show for a certain map, set this to the mapname of that map
Coordinates coordinates Where the marker is placed on the map. Format is "latitude, longitude"
Icon icon Which icon to use for the marker. Can be any lucide icon.
Colour colour Which colour the marker will be
Minimal zoom minZoom How far zoomed in the map should be before the marker becomes visible

Technically only 'coordinates' is required for the marker to be valid. However you'll likely end up using most of the other settings.

Troubleshooting

If you use the Obsidian and your markers don't show up

Obsidian doesn't support nested YAML via the Note Properties plugin (source). However the Obsidian Leaflet Bases plugin adds tools to simply making and editing markers.

If you use Quartz Syncer and your markers don't show up

Chances are that your Syncer settings don't include all frontmatter/note properties. Try enabling the setting in Quartz Syncer to include all frontmatter/note properties.

Credits

  • Quartz for which this plugin is for.
  • Lucide for the API this plugin uses to load its icons.
  • Leaflet which makes the whole plugin even possible.

Make a new release

git tag -a 1.0.1 -m "1.0.1"
git push origin 1.0.1