How to obtain absolute file paths (for images)? #990
-
Intention:I'd like to create a remark-plugin that converts The problem:I have no reference to the actual image file. Approaches / Research(A) I tried two ways:
The information I get for an image:
The the file object I get through transformer:
(B) Context:I am using Remark through Astro so the issue might also arise from there. (C) In Issue 7 of remark-embed-images I also read (but didn't really understand it):
(D) Gatsby Plugin:I also found gatsby-remark-images which basically does what I need but the code seems to be tailored to Gatsby. Question:Is something like this possible? Thanks already in advance 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi there! The answer is: it depends. First of all. This is not what remark is for. remark is about markdown. This is about HTML. You want rehype. More on the difference is available in several docs, including this one in
Well, where are the images?
Perhaps!
It should have a |
Beta Was this translation helpful? Give feedback.
-
In the function header for the remark plugin
Use |
Beta Was this translation helpful? Give feedback.
Hi there! The answer is: it depends. First of all. This is not what remark is for. remark is about markdown. This is about HTML. You want rehype. More on the difference is available in several docs, including this one in
remark-rehype
.Well, where are the images?
Perhaps!
It should have a
path
(which is a getter, so you don’t easily see it in the console when printingfile
, what do you see if you printfile.path
). If it doesn’t, then that’s a bug in Astro.