vue3-notion
Version:
Vue 3 Unofficial Notion Renderer
46 lines (45 loc) • 1.41 kB
JavaScript
import { reactive as m, onBeforeMount as f, defineComponent as v, computed as _, ref as d, onMounted as h, openBlock as p, createElementBlock as u } from "vue";
import { d as k, u as y } from "./index-527a0dd3.js";
const n = m({
callbacks: []
}), E = (e) => {
f(() => {
if (document.getElementById("twitter-widgets-js"))
n.callbacks.push(e);
else {
n.callbacks.push(e);
var t = document.createElement("script");
t.id = "twitter-widgets-js", t.src = "https://platform.twitter.com/widgets.js", t.onload = () => n.callbacks.forEach((o) => o()), document.body.appendChild(t);
}
});
}, b = {
key: 1,
class: "notion-tweet-error"
}, g = {
name: "NotionTweet"
}, j = /* @__PURE__ */ v({
...g,
props: { ...k },
setup(e) {
const c = e, { properties: t } = y(c), o = _(() => t.value?.source?.[0]?.[0].split("status/")?.[1].split("?")[0]), a = d(), r = d(), l = () => {
window.twttr?.ready().then(({ widgets: i }) => {
i.createTweetEmbed(o.value, a.value, {}).then((s) => {
r.value = s ? void 0 : "error";
}).catch((s) => {
r.value = s;
});
});
};
return E(l), h(() => {
l();
}), (w, i) => r.value ? (p(), u("div", b, "Error loading Tweet")) : (p(), u("div", {
key: 0,
class: "notion-tweet",
ref_key: "el",
ref: a
}, null, 512));
}
});
export {
j as default
};