-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
1 lines (1 loc) · 11.6 KB
/
index.js
1
(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.ogDescription))])])]),t("a",{staticClass:"k-seo-preview__debugger",attrs:{href:"https://developers.facebook.com/tools/debug/","aria-label":"Facebook Sharing Debugger",target:"_blank",rel:"noopener noreferrer"}},[e._v(" "+e._s(e.$t("open-debugger"))+" "),t("k-icon",{attrs:{type:"open"}})],1)])},w=[],$=l(b,m,w,!1,null,null,null,null);const C=$.exports,y={props:{title:String,url:String,description:String},computed:{origin(){return new URL(this.url).origin},breadcrumbs(){return this.url.split("/").slice(3)}}};var L=function(){var e=this,t=e._self._c;return t("div",[t("div",{staticClass:"k-google-search-preview"},[t("span",{staticClass:"k-google-search-preview__url"},[t("span",[e._v(e._s(e.origin))]),e._l(e.breadcrumbs,function(a,i){return t("span",{key:i,staticClass:"k-google-search-preview__url__breadcrumb"},[e._v(" "+e._s(a)+" ")])})],2),t("h2",{staticClass:"k-google-search-preview__headline"},[e._v(e._s(e.title))]),t("p",{staticClass:"k-google-search-preview__paragraph"},[e._v(" "+e._s(e.description)+" ")])]),t("a",{staticClass:"k-seo-preview__debugger",attrs:{href:"https://search.google.com/search-console","aria-label":"Google Search Console",target:"_blank",rel:"noopener noreferrer"}},[e._v(" "+e._s(e.$t("open-search-console"))+" "),t("k-icon",{attrs:{type:"open"}})],1)])},S=[],x=l(y,L,S,!1,null,null,null,null);const T=x.exports,O={props:{ogTitle:String,ogSiteName:String,ogDescription:String,ogImage:String},computed:{origin(){return new URL(this.url).origin}}};var H=function(){var e=this,t=e._self._c;return t("div",{staticClass:"k-slack-preview"},[t("div",{staticClass:"k-slack-preview__content"},[t("div",{staticClass:"k-slack-preview__site-name"},[e._v(e._s(e.ogSiteName||e.origin))]),t("span",{staticClass:"k-slack-preview__title"},[e._v(e._s(e.ogTitle))]),t("p",{staticClass:"k-slack-preview__description"},[e._v(e._s(e.ogDescription))])]),e.ogImage?t("div",{staticClass:"k-slack-preview__image"},[t("img",{attrs:{src:e.ogImage}})]):e._e()])},R=[],I=l(O,H,R,!1,null,null,null,null);const Z=I.exports,V={components:{GooglePreview:T,FacebookPreview:C,SlackPreview:Z},data(){const s=localStorage.getItem("kSEOPreviewType")??"google";return{label:null,value:null,isLoading:!0,options:[],type:s}},created(){this.isLoading=!0,this.load().then(s=>{this.label=s.label,this.options=s.options}),this.handleLoad(),this.debouncedLoad=this.$helper.debounce(s=>{this.handleLoad(s)},200)},computed:{changes(){return this.$store.getters["content/changes"]()}},methods:{async handleLoad(s){var a,i;this.isLoading=!0;const e=((i=(a=panel.view.props.model)==null?void 0:a.id)==null?void 0:i.replaceAll("/","+"))??"site",t=await panel.api.post(`/k-seo/${e}/seo-preview`,s??this.changes);this.value=t,this.isLoading=!1}},watch:{changes(s){this.debouncedLoad(s)},type(){localStorage.setItem("kSEOPreviewType",this.type)}}};var F=function(){var e=this,t=e._self._c;return t("div",{staticClass:"k-section k-seo-preview"},[t("div",{staticClass:"k-field-header k-seo-preview__label k-label k-field-label"},[t("k-icon",{attrs:{type:"preview"}}),t("span",{staticClass:"k-label-text"},[e._v(e._s(e.label||e.$t("seo-preview")))]),e.isLoading?t("k-loader"):e._e()],1),t("k-select-field",{attrs:{type:"select",name:"seo-preview-type",before:e.$t("seo-preview-for"),options:e.options,empty:!1},model:{value:e.type,callback:function(a){e.type=a},expression:"type"}}),e.value?t("div",{staticClass:"k-seo-preview__inner"},[e.type==="google"?t("google-preview",e._b({},"google-preview",e.value,!1)):e._e(),e.type==="facebook"?t("facebook-preview",e._b({},"facebook-preview",e.value,!1)):e._e(),e.type==="slack"?t("slack-preview",e._b({},"slack-preview",e.value,!1)):e._e()],1):e._e()],1)},P=[],z=l(V,F,P,!1,null,null,null,null);const M=z.exports,U=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"})),j=Object.freeze({import(s){return Object.entries(s).reduce((t,[a,i])=>(t[A(a)]=i.default,t),{})}});function A(s){return s.substring(s.lastIndexOf("/")+1,s.lastIndexOf(".")).toLowerCase()}const D={extends:"k-page-view",data(){return{dirty:!1,robots:{active:!1,state:[]}}},async mounted(){await this.handleLoad()},methods:{openSeoTab(){panel.view.open(panel.view.path+"?tab=seo")},async handleLoad(s){if(!panel.view.props.tabs.some(t=>t.name==="seo"))return;const e=this.model.id.replaceAll("/","+");this.robots=await panel.api.post(`/k-seo/${e}/robots`,s??this.changes)}},computed:{changes(){return this.$store.getters["content/changes"]()},robotsBtn(){const s={responsive:!0,size:"sm",icon:"robots",theme:"positive",text:this.$t("indicator-index"),variant:"filled"};return this.robots.state.includes("no")&&(s.text=this.$t("indicator-any"),s.theme="notice",s.icon="robots-off"),this.robots.state.includes("noindex")&&(s.text=this.$t("indicator-noindex"),s.theme="negative"),s}},watch:{changes(s){(Object.keys(s).some(e=>e.includes("robots"))||this.dirty)&&(this.dirty=!1,this.handleLoad(s),s&&(this.dirty=!0))}}};var N=function(){var e=this,t=e._self._c;return t("k-panel-inside",{staticClass:"k-page-view",attrs:{"data-has-tabs":e.tabs.length>1,"data-id":e.model.id,"data-locked":e.isLocked,"data-template":e.blueprint},scopedSlots:e._u([{key:"topbar",fn:function(){return[e.model.id?t("k-prev-next",{attrs:{prev:e.prev,next:e.next}}):e._e()]},proxy:!0}])},[t("k-header",{staticClass:"k-page-view-header",attrs:{editable:e.permissions.changeTitle&&!e.isLocked},on:{edit:function(a){return e.$dialog(e.id+"/changeTitle")}},scopedSlots:e._u([{key:"buttons",fn:function(){return[t("k-button-group",[e.permissions.preview&&e.model.previewUrl?t("k-button",{staticClass:"k-page-view-preview",attrs:{link:e.model.previewUrl,title:e.$t("open"),icon:"open",target:"_blank",variant:"filled",size:"sm"}}):e._e(),t("k-button",{staticClass:"k-page-view-options",attrs:{disabled:e.isLocked===!0,dropdown:!0,title:e.$t("settings"),icon:"cog",variant:"filled",size:"sm"},on:{click:function(a){return e.$refs.settings.toggle()}}}),t("k-dropdown-content",{ref:"settings",attrs:{options:e.$dropdown(e.id),"align-x":"end"}}),t("k-languages-dropdown"),e.status?t("k-button",e._b({staticClass:"k-page-view-status",attrs:{variant:"filled"},on:{click:function(a){return e.$dialog(e.id+"/changeStatus")}}},"k-button",e.statusBtn,!1)):e._e(),e.robots&&e.robots.active?t("k-button",e._b({staticClass:"k-page-view-status k-page-view-robots",on:{click:e.openSeoTab}},"k-button",e.robotsBtn,!1)):e._e()],1),t("k-form-buttons",{attrs:{lock:e.lock}})]},proxy:!0}])},[e._v(" "+e._s(e.model.title)+" ")]),t("k-model-tabs",{attrs:{tab:e.tab.name,tabs:e.tabs}}),t("k-sections",{attrs:{blueprint:e.blueprint,empty:e.$t("page.blueprint",{blueprint:e.$esc(e.blueprint)}),lock:e.lock,parent:e.id,tab:e.tab}})],1)},E=[],B=l(D,N,E,!1,null,null,null,null);const G=B.exports;panel.plugin("tobimori/seo",{icons:{robots:'<path d="M13.5 2c0 .444-.193.843-.5 1.118V5h5a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3h5V3.118A1.5 1.5 0 1 1 13.5 2ZM6 7a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8a1 1 0 0 0-1-1H6Zm-4 3H0v6h2v-6Zm20 0h2v6h-2v-6ZM9 14.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm6 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" />',"robots-off":'<path fill-rule="evenodd" clip-rule="evenodd" d="M21 16.786V8a3 3 0 0 0-3-3h-5V3.118a1.5 1.5 0 1 0-2 0V5H9.214l2 2H18a1 1 0 0 1 1 1v6.786l2 2ZM2.093 3.507l2.099 2.099A2.995 2.995 0 0 0 3 8v10a3 3 0 0 0 3 3h12c.463 0 .902-.105 1.293-.292l1.9 1.9 1.414-1.415-6.88-6.88a1.5 1.5 0 1 0-2.04-2.04L3.508 2.093 2.093 3.507ZM5 8a1 1 0 0 1 .65-.937L17.585 19H6a1 1 0 0 1-1-1V8Zm-5 2h2v6H0v-6Zm24 0h-2v6h2v-6Zm-13.5 3a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z" />'},sections:j.import(Object.assign({"./sections/heading-structure.vue":k,"./sections/seo-preview.vue":U})),components:{"k-page-view":G}})})();