I want to use Angular Universal for two things: SEO and preview of the site on social media. I know it is possible with static site content.
But what about dynamic content? What if I want search engines and social media crawlers to find not only the main site with a welcome-screen, but individual blog-posts like www.example.com/posts?articleName=what-is-angular-universal-good-for
? Here the route /posts
is handled by a PostsComponent, which subscribes to queryParam articleName
. So it always renders an article which it dynamically fetches from a database.
Would Angular Universal's server-side-rendering be applied here?
I see that Universal does have something called TransferState. But can that be used for dynamic content? I assume if you rebuild the server-side-app every time you update the posts-DB, it should be able to run the rendering on every (dynamically resolved) post. E.g. this would be the action list for the server-side code:
- Prerender Main Site
- Load array of all possible blog-article-URLs from a DB
- Fetch their content and prerender every single one of them
- When User requests a blog post, only the main site and that post is served. All the other other posts are prerendered and available on the server too, but do not get delivered unless explicitly requested
So is that possible or should I stop looking further into Universal?