datopian / datahub

🌀 Rapidly build rich data portals using a modern frontend framework
https://datahub.io/opensource
MIT License
2.17k stars 322 forks source link

[help]: Cannot read properties of undefined (reading 'data') remark-wiki-link #1059

Open windily-cloud opened 5 months ago

windily-cloud commented 5 months ago

I really love this project so much. This is awesome work!!!

But i have some issue:

Cannot read properties of undefined (reading 'data')
    at Object.exitWikiLink (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/@portaljs+remark-wiki-link@1.1.2/node_modules/@portaljs/remark-wiki-link/dist/index.js:350:35)
    at compile (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/mdast-util-from-markdown@2.0.0/node_modules/mdast-util-from-markdown/lib/index.js:337:40)
    at fromMarkdown (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/mdast-util-from-markdown@2.0.0/node_modules/mdast-util-from-markdown/lib/index.js:173:27)
    at parser (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.js:33:12)
    at Function.parse (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/unified@11.0.4/node_modules/unified/lib/index.js:668:12)
    at executor (file:///D:/Project/Pkmer/thino-landpage/node_modules/.pnpm/unified@11.0.4/node_modules/unified/lib/index.js:734:40)
    at new Promise (<anonymous>)

I try to log, wikilink is undefined:

图片

Then i go to see the exit function:

图片

In the remark-wiki-link package, I found that my code were giving me errors, and after checking that wikilink was returning undefined, I returned the node, and it worked. I don't know if this is a problem, or if something is wrong. I'm not sure if this is a problem or what's wrong.

Thx for any reply!

cumany commented 5 months ago

This issue might be caused by the version 2.0 of mdast-util-from-markdown. https://github.com/syntax-tree/mdast-util-from-markdown/commit/18f4bb0f1b720fd30f1c3a7b11e1fac90aa6903f

johndturn commented 4 months ago

I also started experiencing this issue in my Astro site after upgrading from Astro 3 -> 4. According to their docs, it looks like they upgraded the following packages:

Potentially this is an error with this package not being compatible with the latest version of one or more of these dependencies?

yuhangch commented 4 months ago

Since this.exit no longer has a return value, I made the following modifications in my self-maintained version. Currently, it works in my use case, but it is unclear if there are any other issues. Can someone raise a PR to fix this issue? fromMarkdown.ts#L76C3-L76C3

const wikiLink = top(this.stack)
const {
    data: {isEmbed, target, alias},
} = wikiLink;
this.exit(token);
pricebaldwin commented 4 months ago

I am also experiencing this issue! I'll try out @yuhangch's solution against my use case, but I'm also unsure if I will be able to to put up a PR.

Jenniferwonder commented 1 month ago

Add @yuhangch 's modification to exitWikiLink function in remark-wiki-link/dist/index.js works! 👍