-
Notifications
You must be signed in to change notification settings - Fork 10
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
dynamic runtime layouts for SSR #1248
Comments
if I'm doing things correctly (never a sure thing) then dynamic layouts partly work. with a dynamic page, I got the dynamic layout working by importing the getLayout function into the dynamic page then re-exporting in the same object as getFrontmatter():
however either in the dynamic page or in a markdown page, using the "layout" attribute of the frontmatter to refer to the dynamic layout file appears to be nonfunctional. |
A minimal reproduction would help but if I am understanding you correctly, doing this ---
layout: blog
---
# My First Blog Post
This is my first blog post, I hope you like it! Will map to a matching filename in the layouts directory, e.g. src/
layouts/
blog.html # or blog.js Looking at the docs, I can see how this is not as clear as it could be, so if that's what you're referring to, I can definitely make that clarification as part of ProjectEvergreen/www.greenwoodjs.dev#160 |
I have layouts/blog.ts instead of .js |
Ah, I see now. Yeah, in that case that is just something we need to implement, see #1395 . (FWIW, the next batch of ecosystem compat work will primarily focus around TypeScript enhancements for the project, so expect a lot of those related issues to get resolved as part of the 0.32.0 release which should be starting development soon, so hang tight! 🙏 ) |
Summary
Coming out of #955 / #1212 , one follow up feature to track is supporting dynamic layouts during SSR. So while this has been possible
The layout was executed only once at bundle time which means it was only a one time render.
https://github.com/ProjectEvergreen/greenwood/blob/v0.30.0-alpha.2/packages/cli/src/lifecycles/bundle.js#L243
Details
Our "Web Server Components" pattern combined with #882 would be useful for layouts that want to customize
<head>
tags from an external service, like a CMS for example.For compatible build outputs (
greenwood serve
, serverless adapters), the main trick is that I think this this will require bundling layouts into SSR pages like we do for the page itself. Not sure how tricky this will be though. 🤔Additionally, would be nice to support dynamic context layouts too, as currently they are hardcoded to only support HTML.
https://github.com/ProjectEvergreen/greenwood/blob/v0.30.0-alpha.2/packages/cli/src/lib/templating-utils.js#L13
The text was updated successfully, but these errors were encountered: