From a7c2894402e4597711862b545ae1d433dbf130ab Mon Sep 17 00:00:00 2001 From: halafy-ds <66537087+halafy-ds@users.noreply.github.com> Date: Tue, 8 Oct 2024 03:15:52 +0200 Subject: [PATCH 1/2] Add index.d.ts file to "exports" to fix vscode complaining about the types --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c28b102..6596cf5 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "type": "module", "exports": { ".": { + "types": "./dist/node/index.d.ts", "node": "./dist/node/rehype-citation.mjs", "default": "./dist/browser/rehype-citation.mjs" }, From eb46715987a622215d683ed26c64ce72012e4c59 Mon Sep 17 00:00:00 2001 From: halafy-ds <66537087+halafy-ds@users.noreply.github.com> Date: Tue, 8 Oct 2024 03:20:16 +0200 Subject: [PATCH 2/2] Fix a bug preventing the [^ref] palceholder from correctly working --- src/utils.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/utils.js b/src/utils.js index aaf44bb..adc8f5b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -54,19 +54,20 @@ export const getBibliography = async (options, file) => { typeof file.data.frontmatter.bibliography === 'string' ? [file.data.frontmatter.bibliography] : file.data.frontmatter.bibliography - // If local path, get absolute path - for (let i = 0; i < bibliography.length; i++) { - if (!isValidHttpUrl(bibliography[i])) { - if (isNode) { - bibliography[i] = await import('path').then((path) => - path.join(options.path || file.cwd, bibliography[i]) - ) - } else { - throw new Error(`Cannot read non valid bibliography URL in node env.`) - } + } + // If local path, get absolute path + for (let i = 0; i < bibliography.length; i++) { + if (!isValidHttpUrl(bibliography[i])) { + if (isNode) { + bibliography[i] = await import('path').then((path) => + path.join(options.path || file.cwd, bibliography[i]) + ) + } else { + throw new Error(`Cannot read non valid bibliography URL in node env.`) } } } + return bibliography }