summaryrefslogtreecommitdiff
path: root/packages/renderers/renderer-react/server.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2021-05-28 17:19:40 -0500
committerGravatar GitHub <noreply@github.com> 2021-05-28 17:19:40 -0500
commit3df41d23089142ea9b0895110f28a2d4a43a9059 (patch)
tree4b590cdb86e647b479730f5b4f83ee7c147aaf69 /packages/renderers/renderer-react/server.js
parent630c36f3516bb500ca6a4bfe84c972b1093b8177 (diff)
downloadastro-3df41d23089142ea9b0895110f28a2d4a43a9059.tar.gz
astro-3df41d23089142ea9b0895110f28a2d4a43a9059.tar.zst
astro-3df41d23089142ea9b0895110f28a2d4a43a9059.zip
Bugbash! (#263)
* fix(vscode): Markdown frontmatter should use TSX, not YAML * test: add test for #153 * chore: bump deps * chore: update to use @astrojs scope * fix: Markdown parse error when only child is `{expression}` * fix: update renderer edge cases * fix: failing test * fix: update renderer
Diffstat (limited to 'packages/renderers/renderer-react/server.js')
-rw-r--r--packages/renderers/renderer-react/server.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/renderers/renderer-react/server.js b/packages/renderers/renderer-react/server.js
new file mode 100644
index 000000000..3518f6447
--- /dev/null
+++ b/packages/renderers/renderer-react/server.js
@@ -0,0 +1,21 @@
+import { createElement as h } from 'react';
+import { renderToStaticMarkup as renderToString } from 'react-dom/server.js';
+import StaticHtml from './static-html.js';
+
+function check(Component, props, children) {
+ try {
+ const { html } = renderToStaticMarkup(Component, props, children)
+ return Boolean(html)
+ } catch (e) {}
+ return false;
+}
+
+function renderToStaticMarkup(Component, props, children) {
+ const html = renderToString(h(Component, { ...props, children: h(StaticHtml, { value: children }), innerHTML: children }));
+ return { html };
+}
+
+export default {
+ check,
+ renderToStaticMarkup,
+};
amp;d=retro' width='13' height='13' alt='Gravatar' /> Chloe Arciniega 3-2/+7 file (#12829) * fix: revert content-type changes * chore: changeset 2024-12-24patch: update partytown dependencies (#12822)Gravatar Scott Davis 4-15/+28 2024-12-23[ci] formatGravatar Louis Escher 1-1/+1 2024-12-23Fix server island script breaking when charset is added to content-type (#12810)Gravatar Louis Escher 5-1/+28 2024-12-20fix(toolbar): assign label to icons (#12734)Gravatar Emanuele Stoppa 3-6/+6 2024-12-20fix: better logs for invalid content config (#12798)Gravatar Matt Kane 6-4/+69 Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> 2024-12-20[ci] release (#12790)astro@5.1.1@astrojs/vue@5.0.3@astrojs/tailwind@5.1.4@astrojs/svelte@7.0.2@astrojs/studio@0.1.3@astrojs/solid-js@5.0.1@astrojs/react@4.1.2@astrojs/preact@4.0.1@astrojs/mdx@4.0.3@astrojs/markdoc@0.12.4@astrojs/db@0.14.5@astrojs/alpinejs@0.4.1Gravatar Houston (Bot) 51-124/+177 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2024-12-20fix(deps): upgrade Vite (#12799)Gravatar Matt Kane 14-84/+152 2024-12-20update comment in packages/astro/src/types/public/common.ts (#12782)Gravatar Hiromasa Fujimori 2-1/+6 2024-12-19[ci] formatGravatar Matt Kane 1-4/+2 2024-12-19fix: pass raw frontmatter to when parsing markdown in glob loader (#12789)Gravatar Matt Kane 13-1/+171 2024-12-19chore: move files to `.mjs` (#12765)Gravatar Emanuele Stoppa 2-0/+0 2024-12-19chore: fix links in session errors (#12787)Gravatar Matt Kane 1-4/+4 2024-12-19[ci] release (#12762)astro@5.1.0Gravatar Houston (Bot) 33-159/+140 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>