UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

70 lines (69 loc) 2.54 kB
import { defineComponent as f, computed as k, createElementBlock as n, createCommentVNode as d, openBlock as t, normalizeClass as g, withModifiers as u, createElementVNode as m, createVNode as s, withCtx as i, createTextVNode as p, Fragment as b } from "vue"; import c from "github-slugger"; import w from "../../../../components/Badge/Badge.vue.js"; import { downloadDocument as v } from "../../../../libs/download.js"; const T = ["href"], I = /* @__PURE__ */ f({ __name: "DownloadLink", props: { title: {}, getOriginalDocument: { type: Function }, url: {}, documentDownloadType: {} }, setup(a) { const y = new c(), D = k(() => y.slug(a.title ?? "")), l = (e) => { v(a.getOriginalDocument?.() ?? "", D.value, e); }; return (e, o) => ["yaml", "json", "both"].includes(e.documentDownloadType) ? (t(), n("div", { key: 0, class: g(["download-container group", { "download-both": e.documentDownloadType === "both" }]) }, [ e.documentDownloadType === "json" || e.documentDownloadType === "both" ? (t(), n("button", { key: 0, class: "download-button", type: "button", onClick: o[0] || (o[0] = u((r) => l("json"), ["prevent"])) }, [ o[4] || (o[4] = m("span", null, " Download OpenAPI Document ", -1)), s(w, { class: "extension hidden group-hover:flex" }, { default: i(() => o[3] || (o[3] = [ p("json") ])), _: 1, __: [3] }) ])) : d("", !0), e.documentDownloadType === "yaml" || e.documentDownloadType === "both" ? (t(), n("button", { key: 1, class: "download-button", type: "button", onClick: o[1] || (o[1] = u((r) => l("yaml"), ["prevent"])) }, [ o[6] || (o[6] = m("span", null, " Download OpenAPI Document ", -1)), s(w, { class: "extension hidden group-hover:flex" }, { default: i(() => o[5] || (o[5] = [ p("yaml") ])), _: 1, __: [5] }) ])) : d("", !0) ], 2)) : e.documentDownloadType === "direct" ? (t(), n(b, { key: 1 }, [ e.url ? (t(), n("a", { key: 0, class: "download-link", href: e.url }, " Download OpenAPI Document ", 8, T)) : (t(), n("a", { key: 1, class: "download-link", href: "#", onClick: o[2] || (o[2] = u((r) => l("json"), ["prevent"])) }, " Download OpenAPI Document ")) ], 64)) : d("", !0); } }); export { I as default };