Skip to content

Commit

Permalink
Merge pull request #44 from halafy-ds/main
Browse files Browse the repository at this point in the history
Fix package json node exports to solve types resolution problem and Bug fix preventing [^ref] from working properly for node.
  • Loading branch information
timlrx authored Oct 10, 2024
2 parents 8a967fb + eb46715 commit 1fafdf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
21 changes: 11 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1fafdf6

Please sign in to comment.