aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/vue/src/static-html.ts
diff options
context:
space:
mode:
authorGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
committerGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
commite586d7d704d475afe3373a1de6ae20d504f79d6d (patch)
tree7e3fa24807cebd48a86bd40f866d792181191ee9 /packages/integrations/vue/src/static-html.ts
downloadastro-latest.tar.gz
astro-latest.tar.zst
astro-latest.zip
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'packages/integrations/vue/src/static-html.ts')
-rw-r--r--packages/integrations/vue/src/static-html.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/integrations/vue/src/static-html.ts b/packages/integrations/vue/src/static-html.ts
new file mode 100644
index 000000000..689b56a70
--- /dev/null
+++ b/packages/integrations/vue/src/static-html.ts
@@ -0,0 +1,33 @@
+import { defineComponent, h } from 'vue';
+
+/**
+ * Astro passes `children` as a string of HTML, so we need
+ * a wrapper `div` to render that content as VNodes.
+ *
+ * This is the Vue + JSX equivalent of using `<div v-html="value" />`
+ */
+const StaticHtml = defineComponent({
+ props: {
+ value: String,
+ name: String,
+ hydrate: {
+ type: Boolean,
+ default: true,
+ },
+ },
+ setup({ name, value, hydrate }) {
+ if (!value) return () => null;
+ let tagName = hydrate ? 'astro-slot' : 'astro-static-slot';
+ return () => h(tagName, { name, innerHTML: value });
+ },
+});
+
+/**
+ * Other frameworks have `shouldComponentUpdate` in order to signal
+ * that this subtree is entirely static and will not be updated
+ *
+ * Fortunately, Vue is smart enough to figure that out without any
+ * help from us, so this just works out of the box!
+ */
+
+export default StaticHtml;