-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
🐛 BUG: Remark plugin transformer file.path returns undefined #3264
Copy link
Copy link
Closed
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: markdownRelated to Markdown (scope)Related to Markdown (scope)
Description
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:
- I struggled to obtain the absolute file paths of the .md (or the images) so I opened a thread in the remarkjs discussions
- The maintainer wooorm mentioned that
file.pathshould return well the file path. But it seems in Astro it doesn't (see StackBlitz) - 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
- P3: minor bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)feat: markdownRelated to Markdown (scope)Related to Markdown (scope)