Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Remark plugin transformer file.path returns undefined #3264

Closed
1 task done
stephanbogner opened this issue May 3, 2022 · 3 comments · Fixed by #3410
Closed
1 task done

🐛 BUG: Remark plugin transformer file.path returns undefined #3264

stephanbogner opened this issue May 3, 2022 · 3 comments · Fixed by #3410
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: markdown Related to Markdown (scope)

Comments

@stephanbogner
Copy link
Contributor

What version of astro are you using?

1.0.0-beta.20

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Whatever StackBlitz uses

Describe the Bug

Intention:

I am trying to create a remark-plugin that allows having image-files right next to .md files.

Approach:

  1. I struggled to obtain the absolute file paths of the .md (or the images) so I opened a thread in the remarkjs discussions
  2. The maintainer wooorm mentioned that file.path should return well the file path. But it seems in Astro it doesn't (see StackBlitz)
  3. Woorm also replied that the root cause might be this bit of code in the Astro source code

Relevant bit of code:

export default function (pluginOptions) {
  const transformer = (tree, file) => {
    console.log('Transformer data:');
    console.log(file.path); // -> returns undefined
  };

  return transformer;
}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-3cnfvx-nsf5xw?file=custom-remark-plugin/index.mjs

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re natemoo-re added feat: markdown Related to Markdown (scope) - P3: minor bug An edge case that only affects very specific usage (priority) s1-small and removed bb:investigate labels May 10, 2022
@natemoo-re
Copy link
Member

natemoo-re commented May 10, 2022

Yep, looks like we could improve the way we're calling process here. I'll try to get this prioritized!

Thanks very much for the thorough reproduction, context, and links!

@stephanbogner
Copy link
Contributor Author

No worries, you're welcome! And thanks for trying to solve this quickly 😊

@natemoo-re natemoo-re self-assigned this May 19, 2022
@natemoo-re natemoo-re linked a pull request May 19, 2022 that will close this issue
natemoo-re added a commit that referenced this issue May 24, 2022
* feat: use internal MDX tooling for markdown + components

* fix: improve MD + component tests

* chore: add changeset

* fix: make tsc happy

* fix(#3319): add regression test for component children

* fix(markdown): support HTML comments in markdown

* fix(#2474): ensure namespaced components are properly handled in markdown pages

* fix(#3220): ensure html in markdown pages does not have extra surrounding space

* fix(#3264): ensure that remark files pass in file information

* fix(#3254): enable experimentalStaticExtraction for `.md` pages

* fix: revert parsing change

* fix: remove `markdown.mode` option
@stephanbogner
Copy link
Contributor Author

I never replied. Thanks a lot! Works great now! @natemoo-re

SiriousHunter pushed a commit to SiriousHunter/astro that referenced this issue Feb 3, 2023
* feat: use internal MDX tooling for markdown + components

* fix: improve MD + component tests

* chore: add changeset

* fix: make tsc happy

* fix(withastro#3319): add regression test for component children

* fix(markdown): support HTML comments in markdown

* fix(withastro#2474): ensure namespaced components are properly handled in markdown pages

* fix(withastro#3220): ensure html in markdown pages does not have extra surrounding space

* fix(withastro#3264): ensure that remark files pass in file information

* fix(withastro#3254): enable experimentalStaticExtraction for `.md` pages

* fix: revert parsing change

* fix: remove `markdown.mode` option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: markdown Related to Markdown (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants