DEV Community

[Comment from a deleted post]
Collapse
 
jdforsythe profile image
Jeremy Forsythe

I'm attempting something similar with Angular Universal and the pre-renderer in v9. I am having the same issue, with the <markdown> element in the generated html file but no content.

I thought it was related to HttpClient request for the markdown, so I had some scripts which will generate an articles.ts file at build time with all of the markdown, routes, etc. (it also generates my routes.txt file for prerendering). The markdown gets base64-encoded to put into the array. Then the component loads the data from articles.ts, converts it back to ASCII, and puts it in the [data] binding of the <markdown> element.

Now HttpClient was removed from the equation and the content is all available in TypeScript when the pre-renderer runs, however the result is the same - an empty <markdown> element in the rendered HTML.

The odd thing is that I have a "blog" page that lists the articles with thumbnails, data that is also pulled from the same file. It doesn't use ngx-markdown but just creates some cards with normal elements and Angular bindings. That page gets successfully rendered, with the data from the articles.ts file statically in the HTML.

I think it has something to do with the way ngx-markdown works, probably how it calls out to marked for the parsing.

Collapse
 
daviddalbusco profile image
David Dal Busco

Maybe something changed in ngx-markdown? It has been a while since I wrote this blog post (> 2 years) maybe it also need some other adjustments...

 
jdforsythe profile image
Jeremy Forsythe • Edited

I stripped out ngx-markdown and tried using marked directly with the same result.

I did have some success loading the markdown with HttpClient and using marked. The prerender fails on the HTTP requests however if i use http://localhost:4300 in the URLs and run another copy of the app while I'm prerendering, it can successfully find the markdown files and renders properly. If i can just figure out why the relative URL calls are failing, I'll be in business. They are supposed to be rewritten to absolute URLs automatically now but it doesn't appear to be working.

 
daviddalbusco profile image
David Dal Busco

Happy to hear you made progress. Can't help unfortunately, it's been a while since I don't used Angular for SSR. Good luck 🤞