Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject CMS Content to Razor Components at compile time #50817

Closed
mouldt opened this issue Sep 19, 2023 · 8 comments
Closed

Inject CMS Content to Razor Components at compile time #50817

mouldt opened this issue Sep 19, 2023 · 8 comments
Labels
area-blazor Includes: Blazor, Razor Components Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Pillar: Complete Blazor Web

Comments

@mouldt
Copy link

mouldt commented Sep 19, 2023

Hi,
if you use a CMS with your site but the content is mainly static e.g. home, contact, about us etc - how does this fit with Blazor?
With other SPA frameworks e.g. Nuxt.js there are CMS systems that process and inject their content to the pages at build time.
So, for example, you could have a markdown file or a liquid template (index.liquid) NOTE: this could even contain frontmatter to enable add meta tags to the head to improve SEO.
At build time a 'processor' would examine the razor component and replace a tag with the processed content of the CMS file. From then on its just the normal razor compilation.
The benefit, as i see it, is twofold:

  1. The content is extracted into something a less tech savvy person can deal with e.g. Markdown
  2. The razor page is then able to also be pre-rendered to a static html page, with the content embedded, so its not an API call cost every time the page is rendered but a one-time cost at build time. This yield SEO and page performance benefits.

Could we have this functionality/experience with Blazor?

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Sep 19, 2023
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
it's not very clear what exactly you're asking for. Are you asking for static-site generation support at compile time?

@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Sep 19, 2023
@ghost
Copy link

ghost commented Sep 19, 2023

Hi @mouldt. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@marinasundstrom
Copy link

marinasundstrom commented Sep 19, 2023

@mouldt Are you talking about using Blazor as a static site generator that produces static files? Like having markdown files and compile them to pages like some JS framework do?

There is no such thing in Blazor. But I guess that someone could create build tasks that could do that. It is not just included in Blazor.

If you are looking for prerendering of Blazor WASM pages, then I recommend this: https://github.com/jsakamoto/BlazorWasmPreRendering.Build

That is what I'm using for my own webpage which is hosted by GitHub Pages.

@mouldt
Copy link
Author

mouldt commented Sep 20, 2023

@marinasundstrom - yes exactly that, a static site generator but producing the files from markdown and razor components. These pages are then used as the direct landing page that a user can navigate to, so they render the page quickly, then they hydrate the blazor app in the background and then switch, so you get the best of both worlds.

I did look at https://github.com/jsakamoto/BlazorWasmPreRendering.Build
but this would need to be enhanced to deal with the markdown injection aspect. I will take a look and see what I can come up with.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Sep 20, 2023
@marinasundstrom
Copy link

marinasundstrom commented Sep 20, 2023

@mouldt I know that Astro has MDX which is a mix of Markdown and JSX.

Blazor does not have that. But it's giving me ideas for enhancing my blog.

Feel free to experiment if you want to.

Some resources:

You could simply combine these resources - then create a MSBuild task. Of course, there is more to do, like editor experience etc.

@javiercn
Copy link
Member

@mouldt thanks for the additional details.

We do have support for rendering components outside of the HTTP context, which is the basis for you to build something like that, by rendering from a console app or similar, but we do not offer an out of the box solution for it.

@javiercn javiercn added this to the .NET 9 Planning milestone Sep 27, 2023
@ghost
Copy link

ghost commented Sep 27, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT
Copy link
Member

Closing as a dupe of #51046

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Pillar: Complete Blazor Web
Projects
None yet
Development

No branches or pull requests

5 participants