Open RehanSaeed opened 4 years ago
Having the same issue.
I was just searching for a solution to this problem myself. I am working on a markdown powered site with a number of remark plugins and the feeds (atom, xml, json) contain raw markdown at the moment.
@scottsweb - I fixed it with the workaround mentioned by @RehanSaeed, but still.
The workaround has one big downside: any images in content will not work, due to whatever markdown transformer you'd end up using not knowing about the transforms gridsome does to the image paths. Same applies to links to other resources/attachments in content that rely on gridsome packing them up while importing the markdown files.
Yes, tonight I discovered the same problem that @freaktechnik mentioned. If you manually render your HTML from the markdown node.content
then you end up with incorrect image URLs because of how Gridsome processes them, packs them, and organizes images for you in the dist/
folder. This means that this workaround simply will NOT work with images (or at least locally hosted ones).
According to https://github.com/gridsome/gridsome/issues/514#issuecomment-510481670 it appears that the Remark Transformer only runs when a GraphQL query is made for each post. This is a strange architectural decision for Gridsome since you would ideally run this during the build process for each post and not have to do it again. Then any plugins that run on api.afterBuild()
would have access to the processed content. But unfortunately, I imagine that making a change as extreme as this would probably require a breaking change in Gridsome to fix (having the transformer run on build instead of on query).
So... the "solution" is to have a GraphQL query in the Feed Plugin. I'm going to look into this tomorrow to see if I can engineer a PR for this plugin that would use a GraphQL query to get the posts for your feed.
Advantages of this method:
Disadvantages of this method:
I've spent two nights just figuring out the problem (that the transformer only runs when you query GraphQL ). So I'm going to pick this project up tomorrow or the next day. But I don't think it will be too hard to implement using the GraphQL query, and it will largely solve everyone's issues.
The feed output is coming out as markdown and not HTML. There is a workaround in https://github.com/gridsome/gridsome/issues/514#issuecomment-510481670l to use
marked
but that does not include any custom remark plugins you may have added.