-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(v2): allow users to specify a custom ssr HTML template #3387
Conversation
Deploy preview for docusaurus-2 failed. Built with commit 27e4f32 https://app.netlify.com/sites/docusaurus-2/deploys/5f4e9f9d50b92f0008a0b867 |
Deploy preview for docusaurus-2 ready! Built with commit c76b498 |
Hi, What is the true motivation behind this feature? implement the defer mode (#3237) asap? I'm not against, but what is annoying me is that this expose additional internals, like the variables we pass to the template etc, that now become part of the API surface. If we ship this, I don't want to guarantee that we won't ever refactor this template, so the users using it expose themselves to potential breaking changes, and I'd rather not have to maintain the doc of this API contract. So basically the idea is: if you do use this feature, you are on your own and you should know what you are doing. |
In my scenario, I would like to:
This only way to do this kind of modification is by having access to the template. I can also imagine a scenario where a user would like to maintain a |
Thanks @mpsq , let's make this happen. Agree that it shouldn't be hard to backport, and it's quite similar to swizzling anyway. Can you add some doc with a warning explaining all that? If you find a way to test it, that'd be nice too |
I added the documentation in the last commit. Regarding the tests, I had a look and there is nothing obvious that can be done with unit tests. A good solution to this problem might be to use integration tests: running a webpack ( |
Thanks, that seems fine to me. I also don't see a good way to test this easily |
Released in alpha 63 🎊 please spread the word 🙏 and tell me if this works fine for you |
Thanks @slorber! 🎉 |
@slorber we may want to mention that the template is Eta syntax, not EJS or lodash.template or doT, so people don't get confused 🤔 |
I agree |
Yes, @mpsq do you want to improve a bit the doc? |
Sure, I will have a look ;) |
Motivation
This PR adds a new property to
docusaurus.config.js
so the users can specify their own SSR HTML template:docusaurus.config.js
:Where
ssrTemplate
is a string, such as:This is tested and works as a PoC, if the Docusaurus team wants to process further, I am happy to implement tests + write the corresponding documentation.
Have you read the Contributing Guidelines on pull requests?
Yes.
Test Plan
Not implemented yet - validating the concept first.