@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
57 lines (56 loc) • 2.99 kB
JavaScript
import Badge_default from "../../../components/Badge/Badge.vue.js";
import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, toDisplayString, withCtx, withModifiers } from "vue";
//#region src/blocks/scalar-info-block/components/DownloadLink.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["href"];
var DownloadLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
__name: "DownloadLink",
props: {
documentDownloadType: {},
eventBus: {},
documentUrl: {},
documentType: { default: "openapi" }
},
setup(__props) {
const label = computed(() => __props.documentType === "asyncapi" ? "Download AsyncAPI Document" : "Download OpenAPI Document");
const handleDownloadClick = (format) => {
__props.eventBus.emit("ui:download:document", { format });
};
return (_ctx, _cache) => {
return [
"yaml",
"json",
"both"
].includes(__props.documentDownloadType) || __props.documentDownloadType === "direct" && __props.documentUrl ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(["download-container group", { "download-both": __props.documentDownloadType === "both" }])
}, [
__props.documentDownloadType === "direct" && __props.documentUrl ? (openBlock(), createElementBlock("a", {
key: 0,
class: "download-link download-button",
href: __props.documentUrl
}, [createElementVNode("span", null, toDisplayString(label.value), 1)], 8, _hoisted_1)) : createCommentVNode("", true),
__props.documentDownloadType === "json" || __props.documentDownloadType === "both" ? (openBlock(), createElementBlock("button", {
key: 1,
class: "download-button",
type: "button",
onClick: _cache[0] || (_cache[0] = withModifiers(() => handleDownloadClick("json"), ["prevent"]))
}, [createElementVNode("span", null, toDisplayString(label.value), 1), createVNode(Badge_default, { class: "extension hidden group-hover:flex" }, {
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("json", -1)])]),
_: 1
})])) : createCommentVNode("", true),
__props.documentDownloadType === "yaml" || __props.documentDownloadType === "both" ? (openBlock(), createElementBlock("button", {
key: 2,
class: "download-button",
type: "button",
onClick: _cache[1] || (_cache[1] = withModifiers(() => handleDownloadClick("yaml"), ["prevent"]))
}, [createElementVNode("span", null, toDisplayString(label.value), 1), createVNode(Badge_default, { class: "extension hidden group-hover:flex" }, {
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("yaml", -1)])]),
_: 1
})])) : createCommentVNode("", true)
], 2)) : createCommentVNode("", true);
};
}
});
//#endregion
export { DownloadLink_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=DownloadLink.vue.script.js.map