Leaflet MD#
CLI tool to transplant (sync) your Markdown to Leaflet.
Install#
Install using your favourite JS package manager: bun i -D @sharpmars/leaflet-md
Setup#
To set it up you need to create leaflet-md.config.[js|ts|mjs|mts] and default export the config. Here's an example:
import { defineConfig } from "@sharpmars/leaflet-md";
export default defineConfig({
glob: { pattern: "**/*.md", base: "./testing/posts" },
frontmatter: { type: "yaml", titleKey: "title", descriptionKey: "description", uploadDateKey: "uploadedDate" },
publicationUri: "at://did:plc:irx36xprktslecsbopbwnh5w/pub.leaflet.publication/3m27dfyhhtk2a",
codeblockTheme: "catppuccin-mocha",
prependDoc: {
path: "./testing/leaflet-prepend.md",
replacement: (key, ctx) => {
if (key == "slug") return ctx.file.split(".")[0];
},
},
});
If you want to use JSON you can create leaflet-md.config.json and type in your config in the same way you would in defineConfig.
{
"glob": {
"pattern": "**/*.md",
"base": "./testing/posts"
},
"frontmatter": {
"type": "yaml",
"titleKey": "title",
"descriptionKey": "description",
"uploadDateKey": "uploadedDate"
},
"publicationUri": "at://did:plc:irx36xprktslecsbopbwnh5w/pub.leaflet.publication/3m27dfyhhtk2a",
"prependDoc": {
"path": "./testing/leaflet-prepend.md"
}
}
All options are available here.
Additionally you need to create .env file with BSKY_HANDLE and BSKY_PASSW.
Mapping between record keys and file paths is stored in leaflet-md.map.json.
Placeholders#
To setup placeholder replacement in prepended and appended docs you need to provide replacement function or key-value array.
Example of function replacing placeholder slug with file name is shown in the config example.
Placeholders in Markdown are defined like this {{your-key}}.
Sessions#
Sessions are stored using the OS's credentials manager. For specific details look at these pages for Node and Bun.
If you want to delete the session, you will have to do it manually.
Session saving is skipped when using --nokeyring argument like this leaflet-md --nokeyring sync or if it's run inside a CI environment(requires CI env var set to true).
Development#
To install dependencies:
bun install
To run:
bun run index.ts
This project was created using bun init in bun v1.2.22. Bun is a fast all-in-one JavaScript runtime.