-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
1 lines (1 loc) · 8.16 KB
/
index.js
1
(function(){"use strict";function i(s,e,t,a,r,F,P,V){var o=typeof s=="function"?s.options:s;return e&&(o.render=e,o.staticRenderFns=t,o._compiled=!0),{exports:s,options:o}}const n={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 l=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,r){return t("li",{key:r,class:`k-heading-structure__item level-${a.level} ${e.itemInvalid(a,r)?"is-invalid":""}`,style:`z-index: ${e.value.length-r}`},[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()},c=[],_=i(n,l,c);const v=_.exports,p=Object.freeze(Object.defineProperty({__proto__:null,default:v},Symbol.toStringTag,{value:"Module"})),d={props:{ogTitle:String,url:String,ogDescription:String,ogImage:String},computed:{host(){return new URL(this.url).host}}};var u=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)])},g=[],h=i(d,u,g);const k=h.exports,f={props:{title:String,url:String,description:String},computed:{origin(){return new URL(this.url).origin},breadcrumbs(){return this.url.split("/").slice(3)}}};var b=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,r){return t("span",{key:r,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)])},m=[],w=i(f,b,m);const C=w.exports,y={props:{ogTitle:String,ogSiteName:String,ogDescription:String,ogImage:String},computed:{origin(){return new URL(this.url).origin}}};var $=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()])},L=[],S=i(y,$,L);const x=S.exports,H={components:{GooglePreview:C,FacebookPreview:k,SlackPreview:x},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,r;this.isLoading=!0;const e=((r=(a=panel.view.props.model)==null?void 0:a.id)==null?void 0:r.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 I=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)},O=[],Z=i(H,I,O);const T=Z.exports,M=Object.freeze(Object.defineProperty({__proto__:null,default:T},Symbol.toStringTag,{value:"Module"})),R=Object.freeze({import(s){return Object.entries(s).reduce((t,[a,r])=>(t[j(a)]=r.default,t),{})}});function j(s){return s.substring(s.lastIndexOf("/")+1,s.lastIndexOf(".")).toLowerCase()}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:R.import(Object.assign({"./sections/heading-structure.vue":p,"./sections/seo-preview.vue":M}))})})();