export default { setup() { const { ref, computed } = Vue; const title = ref(""); const link = ref(""); const overview = ref(""); const categories = ref([""]); const date = ref(null); const sent = ref(false); const disabled = computed(() => { return [title, overview, overview, categories].some((input) => input.value == ""); }); const newPad = function () { let name = title.value.trim().replaceAll(" ", "_"); let url = `https://pad.xpub.nl/p/${name}`; window.open(url); return url; }; const submit = function () { if (link.value == "") { link.value = newPad(); } fetch("api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ title: title.value.trim(), link: link.value, overview: overview.value, categories: categories.value.join(", "), date: date.value, }), }); sent.value = true; title.value = ""; link.value = ""; overview.value = ""; categories.value = [""]; date.value = null; }; return { title, link, overview, categories, date, submit, newPad, sent, disabled }; }, template: `

Add a new pad

`, };