{"id":22555905,"url":"https://github.com/inkdropapp/inkdrop-live-export","last_synced_at":"2025-07-09T23:37:47.842Z","repository":{"id":73148969,"uuid":"533182371","full_name":"inkdropapp/inkdrop-live-export","owner":"inkdropapp","description":"A library for programmatically exporting notes to local filesystem from Inkdrop","archived":false,"fork":false,"pushed_at":"2025-03-05T01:16:31.000Z","size":888,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T05:39:41.587Z","etag":null,"topics":["inkdrop"],"latest_commit_sha":null,"homepage":"https://www.inkdrop.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inkdropapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-06T06:00:28.000Z","updated_at":"2025-03-18T14:44:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d0aa14f-b5c0-4961-9a74-4b7aacf997ad","html_url":"https://github.com/inkdropapp/inkdrop-live-export","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/inkdropapp/inkdrop-live-export","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkdropapp%2Finkdrop-live-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkdropapp%2Finkdrop-live-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkdropapp%2Finkdrop-live-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkdropapp%2Finkdrop-live-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inkdropapp","download_url":"https://codeload.github.com/inkdropapp/inkdrop-live-export/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inkdropapp%2Finkdrop-live-export/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264505356,"owners_count":23618928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inkdrop"],"created_at":"2024-12-07T19:09:22.026Z","updated_at":"2025-07-09T23:37:47.824Z","avatar_url":"https://github.com/inkdropapp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Inkdrop Live Export\n===================\n\nAn [Inkdrop](https://www.inkdrop.app/) module which allows you to programmatically export notes to local filesystem via [the local HTTP server](https://docs.inkdrop.app/manual/accessing-the-local-database#accessing-via-http-advanced).\nIt supports live export, which continuously exports notes as the changes occur.\n\n## Prerequisites\n\n* NodeJS \u003e= 18\n* Inkdrop \u003e= 5.5.1\n\n## Demo project\n\nA simple blog:\n\n- https://github.com/craftzdog/craftzdog-uses\n- [Video tutorial](https://youtu.be/3_JE76PKBWE)\n\n## How to use it\n\n### Enable the Inkdrop local server\n\nFollow [the instruction in the documentation](https://docs.inkdrop.app/manual/accessing-the-local-database#accessing-via-http-advanced).\n\nNow you should be able to invoke the API like so:\n\n```sh\ncurl http://username:password@localhost:19840/\n# =\u003e {\"version\":\"5.5.1\",\"ok\":true}\n```\n\n### Install dev-tools plugin\n\nIt helps copy notebook IDs quickly from the context menu.\n\nhttps://my.inkdrop.app/plugins/dev-tools\n\nThen, copy a `bookId` of a notebook you'd like to export by right-clicking the notebook on the sidebar and select **Copy Notebook ID**.\n\n![Copy notebook ID](https://github.com/inkdropapp/inkdrop-dev-tools/raw/v0.1.0/docs/copy-notebook-id.png)\n\n### Install live-export\n\nSuppose that you have a static website project such as a blog or a documentation, and you are in its root directory.\n\n```sh\ncd \u003cPROJECT_ROOT\u003e\nnpm i -D @inkdropapp/live-export\n```\n\n### Example\n\nCreate a file `import.mjs` (It must be an ES Module).\nInitialize a live exporter:\n\n```js\nimport { LiveExporter, toKebabCase } from '@inkdropapp/live-export'\n\nconst liveExport = new LiveExporter({\n  username: 'foo',\n  password: 'bar',\n  port: 19840\n})\n```\n\nThen, start exporting like so:\n\n```js\nconst sub = await liveExport.start({\n  live: true,\n  bookId: '\u003cYOUR_BOOK_ID\u003e',\n  preProcessNote: ({ note, frontmatter, tags }) =\u003e {\n    frontmatter.title = note.title\n    // Convert note title to kebab case (eg. \"kebab-case-note-title\")\n    frontmatter.slug = toKebabCase(note.title)\n    frontmatter.tags = tags.map(t =\u003e t.name)\n  },\n  pathForNote: ({ /* note, */ frontmatter }) =\u003e {\n    // export only if it's public\n    if (frontmatter.public) {\n      return `./\u003cPATH_TO_EXPORT_NOTES\u003e/${frontmatter.slug}.md`\n    } else return false\n  },\n  urlForNote: ({ frontmatter }) =\u003e {\n    if (frontmatter.public) {\n      return `/\u003cURL_TO_LINK_NOTES\u003e/${frontmatter.slug}`\n    } else return false\n  },\n  pathForFile: ({ mdastNode, /* note, file, */ extension, frontmatter }) =\u003e {\n    if (frontmatter.slug \u0026\u0026 mdastNode.alt) {\n      const fn = `${frontmatter.slug}_${toKebabCase(\n        mdastNode.alt\n      )}${extension}`\n      const res = {\n        filePath: `./\u003cPATH_TO_EXPORT_IMAGES\u003e/${fn}`,\n        url: `./\u003cURL_TO_LINK_IMAGES\u003e/${fn}`\n      }\n      // If the `alt` attribute of the image is 'thumbnail', use it as a hero image\n      if (mdastNode.alt === 'thumbnail') {\n        frontmatter.heroImage = res.filePath\n      }\n      return res\n    } else return false\n  },\n  postProcessNote: ({ md }) =\u003e {\n    // Remove the thumbnail image from the Markdown body\n    const md2 = md.replace(/\\!\\[thumbnail\\]\\(.*\\)\\n/, '')\n    return md2\n  }\n})\n```\n\nIf you would like to cancel/stop exporting:\n\n```js\nsub.stop()\n```\n\nAnd run it:\n\n```sh\nnode --experimental-vm-modules import.mjs\n```\n\n\n## `start()` parameters\n\n### `bookId: string`\n\nThe notebook ID to export. Required.\n\n### `live?: boolean`\n\nIf true, it continuously exports as you change notes in Inkdrop.\nIf false, it performs one-time export.\n\n`false` by default.\n\n### `pathForNote(data)`\n\nGenerate a path to export the specified note\n\n* `data.note`: [`Note`](https://docs.inkdrop.app/reference/data-models#note) - The note to export\n* `data.frontmatter`: `Record\u003cstring, any\u003e` - The YAML frontmatter of the note\n* `data.tags`: An array of [`Tag`](https://docs.inkdrop.app/reference/data-models#tag) - The tags of the note\n* Returns: `string | false | Promise\u003c...\u003e` - A destination path to export. If it returns false, the note will be skipped exporting.\n\n### `urlForNote(data)`\n\nGenerate a URL for the specified note.\nIt is necessary to link from the note to another note.\n\n* `data.note`: [`Note`](https://docs.inkdrop.app/reference/data-models#note) - The note to export\n* `data.frontmatter`: `Record\u003cstring, any\u003e` - The YAML frontmatter of the note\n* `data.tags`: An array of [`Tag`](https://docs.inkdrop.app/reference/data-models#tag) - The tags of the note\n* Returns: `string | false | Promise\u003c...\u003e` - A url/relative path. If it returns false, the note will be skipped processing.\n\n### `pathForFile(data)`\n\nGenerate a path and URL to export the specified image file.\n\n* `data.note`: [`Note`](https://docs.inkdrop.app/reference/data-models#note) - The note data\n* `data.mdastNode`: [`Image`](https://github.com/syntax-tree/mdast#image) - The mdast node of the image\n* `data.file`: [`File`](https://docs.inkdrop.app/reference/data-models#file) - The attached image file data to export\n* `data.extension`: `string` - The file extension of the image (e.g., '.jpg', '.png')\n* `data.frontmatter`: `Record\u003cstring, any\u003e` - The YAML frontmatter of the note\n* `data.tags`: An array of [`Tag`](https://docs.inkdrop.app/reference/data-models#tag) - The tags of the note\n* Returns: `{ filePath: string; url: string } | false | Promise\u003c...\u003e` - A destination file path to export and url to link. If it returns false, the image will be skipped exporting.\n\n### `preProcessNote(data)`\n\nPre-process the specified note.\nIt is useful to update the frontmatter information based on the note metadata.\n\n* `data.note`: [`Note`](https://docs.inkdrop.app/reference/data-models#note) - The note data\n* `data.frontmatter`: `Record\u003cstring, any\u003e` - The YAML frontmatter of the note\n* `data.tags`: An array of [`Tag`](https://docs.inkdrop.app/reference/data-models#tag) - The tags of the note\n* `data.mdast`: [`Root`](https://github.com/syntax-tree/mdast#root) - The mdast root node of the note\n* Returns: `any | Promise\u003cany\u003e`\n\n### `postProcessNote(data)`\n\nPost-process the specified note right before writing the note to a file.\nIt is useful to tweak the Markdown data (e.g., deleting unnecessary lines).\n\n* `data.md`: `string` - The Markdown data\n* `data.frontmatter`: `Record\u003cstring, any\u003e` - The YAML frontmatter of the note\n* `data.tags`: An array of [`Tag`](https://docs.inkdrop.app/reference/data-models#tag) - The tags of the note\n* Returns: `string | Promise\u003cstring\u003e` - Returns the processed Markdown string\n\n## Debugging\n\nSet environment variable `DEBUG='inkdrop:export:info,inkdrop:export:error'` to enable console outputs\n\n## FAQ\n\n### How can I see the access logs of the local server?\n\nRun the app with a `--enable-logging` flag. See [the documentation](https://docs.inkdrop.app/manual/troubleshooting#enable-logging) for more detail.\n\n### Can I import the notes back to Inkdrop?\n\nNo. As it transforms the notes for your projects, they are no longer compatible with Inkdrop.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkdropapp%2Finkdrop-live-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finkdropapp%2Finkdrop-live-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finkdropapp%2Finkdrop-live-export/lists"}