diff options
author | 2021-03-31 16:10:27 -0400 | |
---|---|---|
committer | 2021-03-31 16:10:27 -0400 | |
commit | d9084ff4ad9e25577846d3eb53046c2f0066097f (patch) | |
tree | f6ae46756c68c6036d2f861a0373a4686f9efa74 /src/frontend/render/renderer.ts | |
parent | 3fa6396a7b092258c994d0bee6719b89b45c7bf8 (diff) | |
download | astro-d9084ff4ad9e25577846d3eb53046c2f0066097f.tar.gz astro-d9084ff4ad9e25577846d3eb53046c2f0066097f.tar.zst astro-d9084ff4ad9e25577846d3eb53046c2f0066097f.zip |
Implement fallback capability (#44)
* Implement fallback capability
This makes it possible for a dynamic component to render fallback content on the server.
The mechanism is a special `static` prop passed to the component. If `static` is true then the component knows it can render static content.
Putting aside the word `static`, is this the right approach? I think giving components the flexibility to make the decision themselves *is* the right approach.
However in this case we have a special property that is passed in non-explicitly. I think we have to do it this way because if the caller passes in a prop it will get serialized and appear on the client. By making this something we *add* during rendering, it only happens on the server (and only when using `:load`).
Assuming this is the right approach, is `static` the right name for this prop? Other candidates:
* `server`
That's all I have!
* Use `import.meta.env.astro` to tell if running in SSR mode.
* Run formatter
Diffstat (limited to 'src/frontend/render/renderer.ts')
-rw-r--r-- | src/frontend/render/renderer.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/frontend/render/renderer.ts b/src/frontend/render/renderer.ts index d7afc0558..9589cef85 100644 --- a/src/frontend/render/renderer.ts +++ b/src/frontend/render/renderer.ts @@ -5,7 +5,7 @@ interface DynamicRenderContext { } export interface Renderer { - renderStatic(Component: any): (props: Record<string, string>, ...children: any[]) => string; + renderStatic(Component: any): (props: Record<string, any>, ...children: any[]) => string; render(context: { root: string; Component: string; props: string; [key: string]: string }): string; imports?: Record<string, string[]>; } |