From b3e91082c725619295dbbd7cc6ec7ea48284ea62 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sun, 22 Oct 2023 01:26:48 +0800 Subject: [PATCH] fix build --- package.json | 3 ++- src/convertors/roam/roam-backlinks.ts | 9 ++++++--- src/helpers/markdown/markdown.ts | 4 ++-- src/helpers/markdown/plugins/parse-tags.ts | 4 ++-- yarn.lock | 13 +++++++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index fa05f78..f84b24a 100644 --- a/package.json +++ b/package.json @@ -50,10 +50,11 @@ "@size-limit/preset-small-lib": "^8.1.0", "@types/js-yaml": "^4.0.5", "@types/lodash-es": "^4.17.6", + "@types/prettier": "^2.0.0", "@types/wicg-file-system-access": "^2020.9.6", "bumpp": "^9.1.0", "eslint": "^8.28.0", - "prettier": "^2.8.0", + "prettier": "^2.8.8", "size-limit": "^8.1.0", "tsup": "^6.5.0", "typescript": "^4.9.3", diff --git a/src/convertors/roam/roam-backlinks.ts b/src/convertors/roam/roam-backlinks.ts index 9ce5ec3..a3001b2 100644 --- a/src/convertors/roam/roam-backlinks.ts +++ b/src/convertors/roam/roam-backlinks.ts @@ -39,8 +39,11 @@ export class RoamBacklinks { // We want to iterate deeply through the note and map // all the titles to their corresponding note IDs. private processNote(note: RoamNote, result: TitleToIdMap = new Map()) { - this.titleToIdMap.set(note.title, normalizeUidToId(note.uid)) - this.idToTitleMap.set(normalizeUidToId(note.uid), note.title) + const id = normalizeUidToId(note.uid) + const title = note.title || id + + this.titleToIdMap.set(title, id) + this.idToTitleMap.set(id, title) if (note.children) { note.children.map((child) => { @@ -64,7 +67,7 @@ export class RoamBacklinks { // We are treating noteString.uid as the block ref title this.titleToIdMap.set(noteString.uid, normalizeUidToId(note.uid)) - this.idToTitleMap.set(normalizeUidToId(noteString.uid), note.title) + this.idToTitleMap.set(normalizeUidToId(noteString.uid), note.title || "") if (noteString.children) { noteString.children.map((child) => { diff --git a/src/helpers/markdown/markdown.ts b/src/helpers/markdown/markdown.ts index 1ba9349..3f4d1ae 100644 --- a/src/helpers/markdown/markdown.ts +++ b/src/helpers/markdown/markdown.ts @@ -27,10 +27,10 @@ export const markdownToHtml = ( const processor = unified() .data('micromarkExtensions', [ - gfmAutolinkLiteral, + gfmAutolinkLiteral(), {disable: {null: constructsToDisable}}, ]) - .data('fromMarkdownExtensions', [gfmAutolinkLiteralFromMarkdown]) + .data('fromMarkdownExtensions', [gfmAutolinkLiteralFromMarkdown()]) .use(pipeToMarkdown) .use(wikiLinkPlugin, { wikiLinkClassName: 'backlink', diff --git a/src/helpers/markdown/plugins/parse-tags.ts b/src/helpers/markdown/plugins/parse-tags.ts index d6fb8a6..f5298d3 100644 --- a/src/helpers/markdown/plugins/parse-tags.ts +++ b/src/helpers/markdown/plugins/parse-tags.ts @@ -1,4 +1,4 @@ -import {type Root, type StaticPhrasingContent} from 'mdast' +import {type Root, type PhrasingContent} from 'mdast' import {findAndReplace, type ReplaceFunction} from 'mdast-util-find-and-replace' import {Plugin} from 'unified' @@ -26,7 +26,7 @@ export const parseTags: Plugin<[ParseTagOptions], Root> = (options: ParseTagOpti const url = buildTagUrl({graphId: options.graphId, linkHost: options.linkHost, tag}) - const node: StaticPhrasingContent = {type: 'text', value} + const node: PhrasingContent = {type: 'text', value} return {type: 'link', title: null, url, children: [node]} } diff --git a/yarn.lock b/yarn.lock index 9a88ead..eeab8c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -503,6 +503,11 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== +"@types/prettier@^2.0.0": + version "2.7.3" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f" + integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA== + "@types/semver@^7.3.12": version "7.3.13" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" @@ -3328,10 +3333,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.8.0: - version "2.8.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632" - integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw== +prettier@^2.8.8: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== prompts@^2.4.2: version "2.4.2"