2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
|
(function(){"use strict";function l(s,e,t,a,i,c,_,X){var n=typeof s=="function"?s.options:s;e&&(n.render=e,n.staticRenderFns=t,n._compiled=!0),a&&(n.functional=!0),c&&(n._scopeId="data-v-"+c);var o;if(_?(o=function(r){r=r||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!r&&typeof __VUE_SSR_CONTEXT__<"u"&&(r=__VUE_SSR_CONTEXT__),i&&i.call(this,r),r&&r._registeredComponents&&r._registeredComponents.add(_)},n._ssrRegister=o):i&&(o=X?function(){i.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:i),o)if(n.functional){n._injectStyles=o;var W=n.render;n.render=function(q,u){return o.call(u),W(q,u)}}else{var d=n.beforeCreate;n.beforeCreate=d?[].concat(d,o):[o]}return{exports:s,options:n}}const p={data(){return{label:null,value:null,isLoading:!0}},created(){this.isLoading=!0,this.load().then(s=>{this.label=s.label}),this.handleLoad(),this.debouncedLoad=this.$helper.debounce(s=>{this.handleLoad(s)},200)},computed:{changes(){return this.$store.getters["content/changes"]()},incorrectOrder(){var s;return(s=this.value)==null?void 0:s.some((e,t)=>{var a;return e.level>(((a=this.value[t-1])==null?void 0:a.level)??0)+1})},multipleH1(){var s;return((s=this.value)==null?void 0:s.filter(e=>e.level===1).length)>1},noH1(){var s;return((s=this.value)==null?void 0:s.filter(e=>e.level===1).length)===0}},methods:{async handleLoad(s){this.isLoading=!0;const e=panel.view.props.model.id;if(!e)throw new Error("[kirby-seo] The Heading structure section is only available for pages");const t=await panel.api.post(`/k-seo/${e.replaceAll("/","+")}/heading-structure`,s??this.changes);this.value=t,this.isLoading=!1},itemInvalid(s,e){var t;return!!(s.level>(((t=this.value[e-1])==null?void 0:t.level)??0)+1||s.level===1&&this.value[e-1]||s.level===1&&this.value.filter(a=>a.level===1).length>1)}},watch:{changes(s){this.debouncedLoad(s)}}};var v=function(){var e=this,t=e._self._c;return e.value?t("div",{staticClass:"k-section k-heading-structure"},[t("div",{staticClass:"k-field-header k-heading-structure__label k-label k-field-label"},[t("k-icon",{attrs:{type:"headline"}}),t("span",{staticClass:"k-label-text"},[e._v(e._s(e.label||e.$t("heading-structure")))]),e.isLoading?t("k-loader"):e._e()],1),t("k-box",{attrs:{theme:"white"}},[t("ol",{staticClass:"k-heading-structure__list"},e._l(e.value,function(a,i){return t("li",{key:i,class:`k-heading-structure__item level-${a.level} ${e.itemInvalid(a,i)?"is-invalid":""}`,style:`z-index: ${e.value.length-i}`},[t("span",{staticClass:"k-heading-structure__item__level"},[e._v("H"+e._s(a.level))]),t("span",{staticClass:"k-heading-structure__item__text"},[e._v(e._s(a.text))])])}),0)]),e.incorrectOrder&&!e.noH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("incorrect-heading-order")))])],1):e._e(),e.multipleH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("multiple-h1-tags")))])],1):e._e(),e.noH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("missing-h1-tag")))])],1):e._e()],1):e._e()},g=[],h=l(p,v,g,!1,null,null,null,null);const f=h.exports,k=Object.freeze(Object.defineProperty({__proto__:null,default:f},Symbol.toStringTag,{value:"Module"})),b={props:{ogTitle:String,url:String,ogDescription:String,ogImage:String},computed:{host(){return new URL(this.url).host}}};var m=function(){var e=this,t=e._self._c;return t("div",[t("div",{staticClass:"k-facebook-preview"},[e.ogImage?t("div",{staticClass:"k-facebook-preview__image"},[t("img",{staticClass:"k-facebook-preview__img",attrs:{src:e.ogImage}})]):e._e(),t("div",{staticClass:"k-facebook-preview__content"},[t("span",{staticClass:"k-facebook-preview__url"},[e._v(e._s(e.host))]),t("span",{staticClass:"k-facebook-preview__title"},[e._v(e._s(e.ogTitle))]),t("p",{staticClass:"k-facebook-preview__description"},[e._v(e._s(e.ogDescript
|