feat(ServerComponent): add method to render simplified html#1072
feat(ServerComponent): add method to render simplified html#1072
Conversation
|
bf48e08 was deployed to: https://fred-pr1072.review.mdn.allizom.net/ |
caugner
left a comment
There was a problem hiding this comment.
Could we avoid renderSimple() if an environment variable just caused this effect?
LeoMcA
left a comment
There was a problem hiding this comment.
Could we avoid renderSimple() if an environment variable just caused this effect?
Hmm, let me think about this: I think though it would make the component code more complex, and I think there's a nice simplicity to just having two render methods on components which need them.
caugner
left a comment
There was a problem hiding this comment.
LGTM overall, just three more nits:
- Should the method be called
renderSimplified()orrenderMinimal()to make it clearer what this method does. - Can we mention this in the docs (README?).
- Could every
renderSimple()implementation incl. default implementation explain in JSDoc what it omits?
| /** | ||
| * @param {...any} args | ||
| * @returns {any} | ||
| */ |
There was a problem hiding this comment.
nit: add description of this method
| /** | ||
| * @param {import("@fred").Context<import("@rari").DocPage>} context | ||
| */ |
There was a problem hiding this comment.
nit: explain what this method omits (even if it's comparably trivial from looking at render/renderSimple side-by-side
| /** | ||
| * @param {import("@fred").Context<import("@rari").DocPage>} context | ||
| */ |
There was a problem hiding this comment.
nit: explain what this simplified/minimal rendering omits
Description
renderSimplemethod to the server component class, which can be overwritten in a component to define a simplified HTML version of the componentMotivation
renderSimpleexport inentry.ssr.jsI don't have to set up async local storage, mock fluent, etc.Testing
For a preview of the simple form of a component, run:
And then navigate directly to a doc page (other page types will render nothing), e.g. http://localhost:3000/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger
Screenshot