diff --git a/dist/__chunks__/property.y-6B4rf9.js b/dist/__chunks__/property.y-6B4rf9.js new file mode 100644 index 00000000..662a6108 --- /dev/null +++ b/dist/__chunks__/property.y-6B4rf9.js @@ -0,0 +1,6 @@ +import{u as p,f as l}from"./lit-element.XkUWx5ik.js";/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const d={attribute:!0,type:String,converter:p,reflect:!1,hasChanged:l},h=(r=d,n,t)=>{const{kind:s,metadata:a}=t;let o=globalThis.litPropertyMetadata.get(a);if(o===void 0&&globalThis.litPropertyMetadata.set(a,o=new Map),o.set(t.name,r),s==="accessor"){const{name:e}=t;return{set(i){const c=n.get.call(this);n.set.call(this,i),this.requestUpdate(e,c,r)},init(i){return i!==void 0&&this.P(e,void 0,r),i}}}if(s==="setter"){const{name:e}=t;return function(i){const c=this[e];n.call(this,i),this.requestUpdate(e,c,r)}}throw Error("Unsupported decorator location: "+s)};function f(r){return(n,t)=>typeof t=="object"?h(r,n,t):((s,a,o)=>{const e=a.hasOwnProperty(o);return a.constructor.createProperty(o,e?{...s,wrapped:!0}:s),e?Object.getOwnPropertyDescriptor(a,o):void 0})(r,n,t)}export{f as n}; +//# sourceMappingURL=property.y-6B4rf9.js.map diff --git a/dist/__chunks__/property.y-6B4rf9.js.map b/dist/__chunks__/property.y-6B4rf9.js.map new file mode 100644 index 00000000..f78b1df3 --- /dev/null +++ b/dist/__chunks__/property.y-6B4rf9.js.map @@ -0,0 +1 @@ +{"version":3,"file":"property.y-6B4rf9.js","sources":["../../node_modules/@lit/reactive-element/decorators/property.js"],"sourcesContent":["import{defaultConverter as t,notEqual as e}from\"../reactive-element.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),\"accessor\"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if(\"setter\"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error(\"Unsupported decorator location: \"+n)};function n(t){return(e,o)=>\"object\"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty};\n//# sourceMappingURL=property.js.map\n"],"names":["o","t","e","r","n","i","s"],"mappings":"qDACA;AAAA;AAAA;AAAA;AAAA,GAIG,MAAMA,EAAE,CAAC,UAAU,GAAG,KAAK,OAAO,UAAUC,EAAE,QAAQ,GAAG,WAAWC,CAAC,EAAEC,EAAE,CAACF,EAAED,EAAEE,EAAEC,IAAI,CAAC,KAAK,CAAC,KAAKC,EAAE,SAASC,CAAC,EAAEF,EAAE,IAAIG,EAAE,WAAW,oBAAoB,IAAID,CAAC,EAAE,GAAYC,IAAT,QAAY,WAAW,oBAAoB,IAAID,EAAEC,EAAE,IAAI,GAAG,EAAEA,EAAE,IAAIH,EAAE,KAAKF,CAAC,EAAeG,IAAb,WAAe,CAAC,KAAK,CAAC,KAAKJ,CAAC,EAAEG,EAAE,MAAM,CAAC,IAAIA,EAAE,CAAC,MAAMC,EAAEF,EAAE,IAAI,KAAK,IAAI,EAAEA,EAAE,IAAI,KAAK,KAAKC,CAAC,EAAE,KAAK,cAAcH,EAAEI,EAAEH,CAAC,CAAC,EAAE,KAAKC,EAAE,CAAC,OAAgBA,IAAT,QAAY,KAAK,EAAEF,EAAE,OAAOC,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAC,GAAcE,IAAX,SAAa,CAAC,KAAK,CAAC,KAAKJ,CAAC,EAAEG,EAAE,OAAO,SAASA,EAAE,CAAC,MAAMC,EAAE,KAAKJ,CAAC,EAAEE,EAAE,KAAK,KAAKC,CAAC,EAAE,KAAK,cAAcH,EAAEI,EAAEH,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,mCAAmCG,CAAC,CAAC,EAAE,SAASA,EAAEH,EAAE,CAAC,MAAM,CAACC,EAAEF,IAAc,OAAOA,GAAjB,SAAmBG,EAAEF,EAAEC,EAAEF,CAAC,GAAG,CAACC,EAAEC,EAAE,IAAI,CAAC,MAAMC,EAAED,EAAE,eAAe,CAAC,EAAE,OAAOA,EAAE,YAAY,eAAe,EAAEC,EAAE,CAAC,GAAGF,EAAE,QAAQ,EAAE,EAAEA,CAAC,EAAEE,EAAE,OAAO,yBAAyBD,EAAE,CAAC,EAAE,MAAM,GAAGD,EAAEC,EAAEF,CAAC,CAAC","x_google_ignoreList":[0]} \ No newline at end of file diff --git a/dist/counter/counter.js b/dist/counter/counter.js index 7cf14ba6..32ee9dff 100644 --- a/dist/counter/counter.js +++ b/dist/counter/counter.js @@ -1,6 +1,2 @@ -import{u as p,f as d,i as f,s as h,x as m}from"../__chunks__/lit-element.XkUWx5ik.js";import{t as b}from"../__chunks__/custom-element.qyLKk-84.js";/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const g={attribute:!0,type:String,converter:p,reflect:!1,hasChanged:d},v=(t=g,e,o)=>{const{kind:i,metadata:r}=o;let s=globalThis.litPropertyMetadata.get(r);if(s===void 0&&globalThis.litPropertyMetadata.set(r,s=new Map),s.set(o.name,t),i==="accessor"){const{name:n}=o;return{set(a){const u=e.get.call(this);e.set.call(this,a),this.requestUpdate(n,u,t)},init(a){return a!==void 0&&this.P(n,void 0,t),a}}}if(i==="setter"){const{name:n}=o;return function(a){const u=this[n];e.call(this,a),this.requestUpdate(n,u,t)}}throw Error("Unsupported decorator location: "+i)};function y(t){return(e,o)=>typeof o=="object"?v(t,e,o):((i,r,s)=>{const n=r.hasOwnProperty(s);return r.constructor.createProperty(s,n?{...i,wrapped:!0}:i),n?Object.getOwnPropertyDescriptor(r,s):void 0})(t,e,o)}var P=Object.defineProperty,w=Object.getOwnPropertyDescriptor,l=(t,e,o,i)=>{for(var r=i>1?void 0:i?w(e,o):e,s=t.length-1,n;s>=0;s--)(n=t[s])&&(r=(i?n(e,o,r):n(r))||r);return i&&r&&P(e,o,r),r};let c=class extends h{constructor(){super(...arguments),this.count=0}firstUpdated(){console.log("first updated")}render(){return m`

Lit Counter

`}_onClick(){this.count++}};c.styles=f`:host{max-width:1280px;margin:0 auto;padding:2rem;text-align:center;display:flex;flex-direction:column}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#bada55;color:#333;cursor:pointer;transition:border-color .25s;width:100%}button:hover{background-color:#1a1a1a;color:#f9f9f9}`;l([y({type:Number})],c.prototype,"count",2);c=l([b("lit-counter")],c);function O(t){const e=t.innerHTML;t.innerHTML=`${e}`,t.style.removeProperty("display")}export{c as LitCounter,O as default}; +import{i as a,s as l,x as p}from"../__chunks__/lit-element.XkUWx5ik.js";import{t as d}from"../__chunks__/custom-element.qyLKk-84.js";import{n as f}from"../__chunks__/property.y-6B4rf9.js";var m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,u=(r,o,i,e)=>{for(var t=e>1?void 0:e?h(o,i):o,s=r.length-1,c;s>=0;s--)(c=r[s])&&(t=(e?c(o,i,t):c(t))||t);return e&&t&&m(o,i,t),t};let n=class extends l{constructor(){super(...arguments),this.count=0}firstUpdated(){console.log("first updated")}render(){return p`

Lit Counter

`}_onClick(){this.count++}};n.styles=a`:host{max-width:1280px;margin:0 auto;padding:2rem;text-align:center;display:flex;flex-direction:column}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#bada55;color:#333;cursor:pointer;transition:border-color .25s;width:100%}button:hover{background-color:#1a1a1a;color:#f9f9f9}`;u([f({type:Number})],n.prototype,"count",2);n=u([d("lit-counter")],n);function x(r){const o=r.innerHTML;r.innerHTML=`${o}`,r.style.removeProperty("display")}export{n as LitCounter,x as default}; //# sourceMappingURL=counter.js.map diff --git a/dist/counter/counter.js.map b/dist/counter/counter.js.map index 4a95d5ef..696ceb1f 100644 --- a/dist/counter/counter.js.map +++ b/dist/counter/counter.js.map @@ -1 +1 @@ -{"version":3,"file":"counter.js","sources":["../../node_modules/@lit/reactive-element/decorators/property.js","../../src/blocks/counter/counter.ts"],"sourcesContent":["import{defaultConverter as t,notEqual as e}from\"../reactive-element.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),\"accessor\"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if(\"setter\"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error(\"Unsupported decorator location: \"+n)};function n(t){return(e,o)=>\"object\"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty};\n//# sourceMappingURL=property.js.map\n","import { LitElement, css, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n/**\n * An example element.\n *\n * @slot - This element has a slot\n * @csspart button - The button\n */\n@customElement('lit-counter')\nexport class LitCounter extends LitElement {\n /**\n * The number of times the button has been clicked.\n */\n @property({ type: Number })\n count = 0;\n\n firstUpdated(): void {\n console.log('first updated');\n }\n\n render() {\n return html`\n
\n

Lit Counter

\n \n
\n `;\n }\n\n private _onClick() {\n this.count++;\n }\n\n static styles = css`\n :host {\n max-width: 1280px;\n margin: 0 auto;\n padding: 2rem;\n text-align: center;\n display: flex;\n flex-direction: column;\n }\n\n button {\n border-radius: 8px;\n border: 1px solid transparent;\n padding: 0.6em 1.2em;\n font-size: 1em;\n font-weight: 500;\n font-family: inherit;\n background-color: #bada55;\n color: #333;\n cursor: pointer;\n transition: border-color 0.25s;\n width: 100%;\n }\n button:hover {\n background-color: #1a1a1a;\n color: #f9f9f9;\n }\n `;\n}\n\nexport default function (block: HTMLElement) {\n const org_content = block.innerHTML;\n block.innerHTML = `${org_content}`;\n block.style.removeProperty('display');\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'lit-counter': LitCounter;\n }\n}\n"],"names":["o","t","e","r","n","i","LitCounter","LitElement","html","css","__decorateClass","property","customElement","counter","block","org_content"],"mappings":"mJACA;AAAA;AAAA;AAAA;AAAA,GAIG,MAAMA,EAAE,CAAC,UAAU,GAAG,KAAK,OAAO,UAAUC,EAAE,QAAQ,GAAG,WAAWC,CAAC,EAAEC,EAAE,CAAC,EAAEH,EAAE,EAAEG,IAAI,CAAC,KAAK,CAAC,KAAKC,EAAE,SAASC,CAAC,EAAEF,EAAE,IAAI,EAAE,WAAW,oBAAoB,IAAIE,CAAC,EAAE,GAAY,IAAT,QAAY,WAAW,oBAAoB,IAAIA,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,IAAIF,EAAE,KAAK,CAAC,EAAeC,IAAb,WAAe,CAAC,KAAK,CAAC,KAAKJ,CAAC,EAAEG,EAAE,MAAM,CAAC,IAAIA,EAAE,CAAC,MAAMC,EAAE,EAAE,IAAI,KAAK,IAAI,EAAE,EAAE,IAAI,KAAK,KAAKD,CAAC,EAAE,KAAK,cAAcH,EAAEI,EAAE,CAAC,CAAC,EAAE,KAAKF,EAAE,CAAC,OAAgBA,IAAT,QAAY,KAAK,EAAEF,EAAE,OAAO,CAAC,EAAEE,CAAC,CAAC,CAAC,CAAC,GAAcE,IAAX,SAAa,CAAC,KAAK,CAAC,KAAKJ,CAAC,EAAEG,EAAE,OAAO,SAASA,EAAE,CAAC,MAAMC,EAAE,KAAKJ,CAAC,EAAE,EAAE,KAAK,KAAKG,CAAC,EAAE,KAAK,cAAcH,EAAEI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,mCAAmCA,CAAC,CAAC,EAAE,SAASA,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,IAAc,OAAO,GAAjB,SAAmBD,EAAE,EAAE,EAAE,CAAC,GAAG,CAACF,EAAEC,EAAEF,IAAI,CAAC,MAAMG,EAAED,EAAE,eAAeF,CAAC,EAAE,OAAOE,EAAE,YAAY,eAAeF,EAAEG,EAAE,CAAC,GAAGF,EAAE,QAAQ,EAAE,EAAEA,CAAC,EAAEE,EAAE,OAAO,yBAAyBD,EAAEF,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,CAAC,CAAC,iMCK1vB,IAAAM,EAAN,cAAyBC,CAAW,CAApC,aAAA,CAAA,MAAA,GAAA,SAAA,EAKG,KAAA,MAAA,CAAA,CAER,cAAqB,CACnB,QAAQ,IAAI,eAAe,CAC7B,CAEA,QAAS,CACA,OAAAC,0DAGc,KAAK,QAAQ,4BAA2B,KAAK,KAAK,iBAGzE,CAEQ,UAAW,CACZ,KAAA,OACP,CA8BF,EApDaF,EAwBJ,OAASG,qXAnBhBC,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,CAAA,EAJfL,EAKX,UAAA,QAAA,CAAA,EALWA,EAANI,EAAA,CADNE,EAAc,aAAa,CAAA,EACfN,CAAA,EAsDb,SAAAO,EAAyBC,EAAoB,CAC3C,MAAMC,EAAcD,EAAM,UACpBA,EAAA,UAAY,gBAAgBC,CAAW,iBACvCD,EAAA,MAAM,eAAe,SAAS,CACtC","x_google_ignoreList":[0]} \ No newline at end of file +{"version":3,"file":"counter.js","sources":["../../src/blocks/counter/counter.ts"],"sourcesContent":["import { LitElement, css, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n/**\n * An example element.\n *\n * @slot - This element has a slot\n * @csspart button - The button\n */\n@customElement('lit-counter')\nexport class LitCounter extends LitElement {\n /**\n * The number of times the button has been clicked.\n */\n @property({ type: Number })\n count = 0;\n\n firstUpdated(): void {\n console.log('first updated');\n }\n\n render() {\n return html`\n
\n

Lit Counter

\n \n
\n `;\n }\n\n private _onClick() {\n this.count++;\n }\n\n static styles = css`\n :host {\n max-width: 1280px;\n margin: 0 auto;\n padding: 2rem;\n text-align: center;\n display: flex;\n flex-direction: column;\n }\n\n button {\n border-radius: 8px;\n border: 1px solid transparent;\n padding: 0.6em 1.2em;\n font-size: 1em;\n font-weight: 500;\n font-family: inherit;\n background-color: #bada55;\n color: #333;\n cursor: pointer;\n transition: border-color 0.25s;\n width: 100%;\n }\n button:hover {\n background-color: #1a1a1a;\n color: #f9f9f9;\n }\n `;\n}\n\nexport default function (block: HTMLElement) {\n const org_content = block.innerHTML;\n block.innerHTML = `${org_content}`;\n block.style.removeProperty('display');\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'lit-counter': LitCounter;\n }\n}\n"],"names":["LitCounter","LitElement","html","css","__decorateClass","property","customElement","counter","block","org_content"],"mappings":"4XAUa,IAAAA,EAAN,cAAyBC,CAAW,CAApC,aAAA,CAAA,MAAA,GAAA,SAAA,EAKG,KAAA,MAAA,CAAA,CAER,cAAqB,CACnB,QAAQ,IAAI,eAAe,CAC7B,CAEA,QAAS,CACA,OAAAC,0DAGc,KAAK,QAAQ,4BAA2B,KAAK,KAAK,iBAGzE,CAEQ,UAAW,CACZ,KAAA,OACP,CA8BF,EApDaF,EAwBJ,OAASG,qXAnBhBC,EAAA,CADCC,EAAS,CAAE,KAAM,OAAQ,CAAA,EAJfL,EAKX,UAAA,QAAA,CAAA,EALWA,EAANI,EAAA,CADNE,EAAc,aAAa,CAAA,EACfN,CAAA,EAsDb,SAAAO,EAAyBC,EAAoB,CAC3C,MAAMC,EAAcD,EAAM,UACpBA,EAAA,UAAY,gBAAgBC,CAAW,iBACvCD,EAAA,MAAM,eAAe,SAAS,CACtC"} \ No newline at end of file diff --git a/dist/main/main.js b/dist/main/main.js index 7ad6ce6f..436519c7 100644 --- a/dist/main/main.js +++ b/dist/main/main.js @@ -1,4 +1,8 @@ -import{s as S,x as p}from"../__chunks__/lit-element.XkUWx5ik.js";import{t as w}from"../__chunks__/custom-element.qyLKk-84.js";const E="modulepreload",b=function(s){return"/"+s},f={},C=function(e,t,a){let n=Promise.resolve();if(t&&t.length>0){const i=document.getElementsByTagName("link");n=Promise.all(t.map(r=>{if(r=b(r),r in f)return;f[r]=!0;const o=r.endsWith(".css"),l=o?'[rel="stylesheet"]':"";if(!!a)for(let h=i.length-1;h>=0;h--){const u=i[h];if(u.href===r&&(!o||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${r}"]${l}`))return;const c=document.createElement("link");if(c.rel=o?"stylesheet":E,o||(c.as="script",c.crossOrigin=""),c.href=r,document.head.appendChild(c),o)return new Promise((h,u)=>{c.addEventListener("load",h),c.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${r}`)))})}))}return n.then(()=>e()).catch(i=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=i,window.dispatchEvent(r),!r.defaultPrevented)throw i})};function m(s){return typeof s=="string"?s.toLowerCase().replace(/[^0-9a-z]/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):""}const v=(s,e)=>{e.split(",").forEach(t=>{s.classList.add(m(t.trim()))})};function y(s,e=document){const t=s&&s.includes(":")?"property":"name",n=[...e.head.querySelectorAll(`meta[${t}="${s}"]`)].map(i=>i.content).join(", ");return n.length?n:""}function L(s){return m(s).replace(/-([a-z])/g,e=>e[1].toUpperCase())}var A=Object.defineProperty,P=Object.getOwnPropertyDescriptor,M=(s,e,t,a)=>{for(var n=a>1?void 0:a?P(e,t):e,i=s.length-1,r;i>=0;i--)(r=s[i])&&(n=(a?r(e,t,n):r(n))||n);return a&&n&&A(e,t,n),n};let g=class extends S{constructor(){super(...arguments),this.getSubmenuName=s=>s.path.split("/")[1],this.groupByFirstLevelPath=s=>{const e={};return s.forEach(a=>{const n=this.getSubmenuName(a);e[n]||(e[n]=[]),e[n].push({path:a.path,navtitle:a.navtitle})}),Object.values(e).map(a=>a.length===1?a[0]:{navtitle:a[0].path.split("/")[1],children:a})}}createRenderRoot(){return this}async connectedCallback(){super.connectedCallback();const s=await this.fetchSitemap(),e=this.groupByFirstLevelPath(s);console.log("navItems",e)}render(){return p``}renderMenuItems(){return p``}async fetchSitemap(){return(await(await fetch(`${window.hlx.codeBasePath}/query-index.json`)).json()).data}};g=M([w("sidebar-nav")],g);class q{readBlockConfig(e){const t={};return e.querySelectorAll(":scope > div").forEach(a=>{if(a.children){const n=[...a.children];if(n[1]){const i=n[1],r=m(n[0].textContent??"");let o="";if(i.querySelector("a")){const l=[...i.querySelectorAll("a")];l.length===1?o=l[0].href:o=l.map(d=>d.href)}else if(i.querySelector("img")){const l=[...i.querySelectorAll("img")];l.length===1?o=l[0].src:o=l.map(d=>d.src)}else if(i.querySelector("p")){const l=[...i.querySelectorAll("p")];l.length===1?o=l[0].textContent:o=l.map(d=>d.textContent)}else o=a.children[1].textContent;t[r]=o}}}),t}decorateBlocks(e){e.querySelectorAll("div.section > div > div").forEach(this.decorateBlock)}decorateBlock(e){const t=e.classList[0];if(t){e.classList.add("block"),e.dataset.blockName=t;const a=e.parentElement;a==null||a.classList.add(`${t}-wrapper`);const n=e.closest(".section");n&&n.classList.add(`${t}-container`)}}}class x{constructor(e){this.blockService=e}init(e){this.transformSection(e)}transformSection(e){e.querySelectorAll(":scope > div").forEach(t=>{this.adjustMarkup(t),this.processSectionMetaData(t)})}processSectionMetaData(e){const t=e.querySelector("div.section-metadata");if(t){const a=this.blockService.readBlockConfig(t);Object.keys(a).forEach(n=>{n==="style"?a.style.split(",").filter(r=>r).map(r=>m(r.trim())).forEach(r=>e.classList.add(r)):e.dataset[L(n)]=a[n]}),t.parentElement&&t.parentElement.remove()}}adjustMarkup(e){const t=[];let a=!1;[...e.children].forEach(n=>{if(n.tagName==="DIV"||!a){const i=document.createElement("div");t.push(i),a=n.tagName!=="DIV",a&&i.classList.add("default-content-wrapper")}t[t.length-1].append(n)}),t.forEach(n=>e.append(n)),e.classList.add("section"),e.dataset.sectionStatus="initialized",e.style.display="none"}}class B{constructor(e,t){this.sectionService=e,this.blockService=t,this.init=async()=>{this.setup(),await this.loadEager()},this.loadEager=async()=>{if(document.documentElement.lang="en",this.decorateTemplateAndTheme(),document){const n=document.querySelector("body");n&&(n.style.display="none")}const a=document.querySelector("main");a&&(a.setAttribute("id","main"),this.addSidebarContainer(a),this.sectionService.init(a),this.addInnerContainer(a),this.blockService.decorateBlocks(a),await this.loadComponents(),setTimeout(()=>{document.body.removeAttribute("style")},200))},this.loadComponents=async()=>{document.querySelectorAll(".section").forEach(n=>{const i=[],r=n.querySelectorAll("[data-block-name]");if(!r.length){n.style.removeProperty("display");return}r.forEach(o=>{o.style.display="none",i.push({name:o.dataset.blockName,element:o})}),i.length&&i.forEach(async o=>{const l=await C(()=>import(`${window.hlx.codeBasePath}/dist/${o.name}/${o.name}.js`),__vite__mapDeps([]));l.default&&await l.default(o.element)}),n.style.removeProperty("display")})}}setup(){window.hlx=window.hlx||{},window.hlx.RUM_MASK_URL="full",window.hlx.codeBasePath="",window.hlx.lighthouse=new URLSearchParams(window.location.search).get("lighthouse")==="on";const e=document.querySelector('script[src$="/scripts/scripts.js"]');if(e)try{[window.hlx.codeBasePath]=new URL(e.src).pathname.split("/scripts/scripts.js")}catch(t){console.log(t)}}addSidebarContainer(e){const t=document.createElement("div"),a=document.createElement("div"),n=document.createElement("sidebar-nav");a.classList.add("inner"),a.appendChild(n),t.setAttribute("id","sidebar"),t.appendChild(a),e.after(t)}addInnerContainer(e){const t=e.innerHTML;e.innerHTML=`
${t}
`}decorateTemplateAndTheme(){const e=y("template");e&&v(document.body,e);const t=y("theme");t&&v(document.body,t)}}(async function(){const s=new q,e=new x(s);await new B(e,s).init()})(); +import{s as w,x as h}from"../__chunks__/lit-element.XkUWx5ik.js";import{t as E}from"../__chunks__/custom-element.qyLKk-84.js";import{n as b}from"../__chunks__/property.y-6B4rf9.js";const C="modulepreload",$=function(n){return"/"+n},v={},L=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){const i=document.getElementsByTagName("link");r=Promise.all(t.map(a=>{if(a=$(a),a in v)return;v[a]=!0;const o=a.endsWith(".css"),c=o?'[rel="stylesheet"]':"";if(!!s)for(let u=i.length-1;u>=0;u--){const m=i[u];if(m.href===a&&(!o||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${c}`))return;const l=document.createElement("link");if(l.rel=o?"stylesheet":C,o||(l.as="script",l.crossOrigin=""),l.href=a,document.head.appendChild(l),o)return new Promise((u,m)=>{l.addEventListener("load",u),l.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${a}`)))})}))}return r.then(()=>e()).catch(i=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i})};function p(n){return typeof n=="string"?n.toLowerCase().replace(/[^0-9a-z]/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,""):""}const y=(n,e)=>{e.split(",").forEach(t=>{n.classList.add(p(t.trim()))})};function S(n,e=document){const t=n&&n.includes(":")?"property":"name",r=[...e.head.querySelectorAll(`meta[${t}="${n}"]`)].map(i=>i.content).join(", ");return r.length?r:""}function P(n){return p(n).replace(/-([a-z])/g,e=>e[1].toUpperCase())}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */function M(n){return b({...n,state:!0,attribute:!1})}var q=Object.defineProperty,B=Object.getOwnPropertyDescriptor,g=(n,e,t,s)=>{for(var r=s>1?void 0:s?B(e,t):e,i=n.length-1,a;i>=0;i--)(a=n[i])&&(r=(s?a(e,t,r):a(r))||r);return s&&r&&q(e,t,r),r};let f=class extends w{constructor(){super(...arguments),this.getSubmenuName=n=>n.path.split("/")[1],this.groupByFirstLevelPath=n=>{const e={};return n.forEach(s=>{const r=this.getSubmenuName(s);e[r]||(e[r]=[]),e[r].push({path:s.path,navtitle:this.getNavTitle(s)})}),Object.values(e).map(s=>s.length===1?s[0]:{navtitle:s[0].path.split("/")[1],path:s[0].path,children:s})}}createRenderRoot(){return this}async firstUpdated(){const n=await this.fetchSitemap();this.items=this.groupByFirstLevelPath(n)}render(){if(this.items)return h``}renderSubMenu(n){return h`${n.navtitle}`}renderMenuItem(n){return h`
  • ${n.children!==void 0?this.renderSubMenu(n):h`${n.navtitle}`}
  • `}renderMenuItems(){return h``}async fetchSitemap(){return(await(await fetch(`${window.hlx.codeBasePath}/query-index.json`)).json()).data}getNavTitle(n){return n.path==="/"?"Homepage":n.navtitle||n.title}};g([M()],f.prototype,"items",2);f=g([E("sidebar-nav")],f);class A{readBlockConfig(e){const t={};return e.querySelectorAll(":scope > div").forEach(s=>{if(s.children){const r=[...s.children];if(r[1]){const i=r[1],a=p(r[0].textContent??"");let o="";if(i.querySelector("a")){const c=[...i.querySelectorAll("a")];c.length===1?o=c[0].href:o=c.map(d=>d.href)}else if(i.querySelector("img")){const c=[...i.querySelectorAll("img")];c.length===1?o=c[0].src:o=c.map(d=>d.src)}else if(i.querySelector("p")){const c=[...i.querySelectorAll("p")];c.length===1?o=c[0].textContent:o=c.map(d=>d.textContent)}else o=s.children[1].textContent;t[a]=o}}}),t}decorateBlocks(e){e.querySelectorAll("div.section > div > div").forEach(this.decorateBlock)}decorateBlock(e){const t=e.classList[0];if(t){e.classList.add("block"),e.dataset.blockName=t;const s=e.parentElement;s==null||s.classList.add(`${t}-wrapper`);const r=e.closest(".section");r&&r.classList.add(`${t}-container`)}}}class j{constructor(e){this.blockService=e}init(e){this.transformSection(e)}transformSection(e){e.querySelectorAll(":scope > div").forEach(t=>{this.adjustMarkup(t),this.processSectionMetaData(t)})}processSectionMetaData(e){const t=e.querySelector("div.section-metadata");if(t){const s=this.blockService.readBlockConfig(t);Object.keys(s).forEach(r=>{r==="style"?s.style.split(",").filter(a=>a).map(a=>p(a.trim())).forEach(a=>e.classList.add(a)):e.dataset[P(r)]=s[r]}),t.parentElement&&t.parentElement.remove()}}adjustMarkup(e){const t=[];let s=!1;[...e.children].forEach(r=>{if(r.tagName==="DIV"||!s){const i=document.createElement("div");t.push(i),s=r.tagName!=="DIV",s&&i.classList.add("default-content-wrapper")}t[t.length-1].append(r)}),t.forEach(r=>e.append(r)),e.classList.add("section"),e.dataset.sectionStatus="initialized",e.style.display="none"}}class x{constructor(e,t){this.sectionService=e,this.blockService=t,this.init=async()=>{this.setup(),await this.loadEager()},this.loadEager=async()=>{if(document.documentElement.lang="en",this.decorateTemplateAndTheme(),document){const r=document.querySelector("body");r&&(r.style.display="none")}const s=document.querySelector("main");s&&(s.setAttribute("id","main"),this.addSidebarContainer(s),this.sectionService.init(s),this.addInnerContainer(s),this.blockService.decorateBlocks(s),await this.loadComponents(),setTimeout(()=>{document.body.removeAttribute("style")},200))},this.loadComponents=async()=>{document.querySelectorAll(".section").forEach(r=>{const i=[],a=r.querySelectorAll("[data-block-name]");if(!a.length){r.style.removeProperty("display");return}a.forEach(o=>{o.style.display="none",i.push({name:o.dataset.blockName,element:o})}),i.length&&i.forEach(async o=>{const c=await L(()=>import(`${window.hlx.codeBasePath}/dist/${o.name}/${o.name}.js`),__vite__mapDeps([]));c.default&&await c.default(o.element)}),r.style.removeProperty("display")})}}setup(){window.hlx=window.hlx||{},window.hlx.RUM_MASK_URL="full",window.hlx.codeBasePath="",window.hlx.lighthouse=new URLSearchParams(window.location.search).get("lighthouse")==="on";const e=document.querySelector('script[src$="/scripts/scripts.js"]');if(e)try{[window.hlx.codeBasePath]=new URL(e.src).pathname.split("/scripts/scripts.js")}catch(t){console.log(t)}}addSidebarContainer(e){const t=document.createElement("div"),s=document.createElement("div"),r=document.createElement("sidebar-nav");s.classList.add("inner"),s.appendChild(r),t.setAttribute("id","sidebar"),t.appendChild(s),e.after(t)}addInnerContainer(e){const t=e.innerHTML;e.innerHTML=`
    ${t}
    `}decorateTemplateAndTheme(){const e=S("template");e&&y(document.body,e);const t=S("theme");t&&y(document.body,t)}}(async function(){const n=new A,e=new j(n);await new x(e,n).init()})(); function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = [] diff --git a/dist/main/main.js.map b/dist/main/main.js.map index 097742f5..d3bb54f5 100644 --- a/dist/main/main.js.map +++ b/dist/main/main.js.map @@ -1 +1 @@ -{"version":3,"mappings":"y+BAAO,SAASA,EAAYC,EAAc,CACxC,OAAO,OAAOA,GAAS,SACnBA,EACG,cACA,QAAQ,cAAe,GAAG,EAC1B,QAAQ,MAAO,GAAG,EAClB,QAAQ,SAAU,EAAE,EACvB,EACN,CCNa,MAAAC,EAAa,CAACC,EAAsBC,IAAoB,CACnEA,EAAQ,MAAM,GAAG,EAAE,QAASC,GAAM,CAChCF,EAAQ,UAAU,IAAIH,EAAYK,EAAE,KAAM,EAAC,EAC5C,CACH,ECNgB,SAAAC,EAAYL,EAAcM,EAAM,SAAU,CACxD,MAAMC,EAAOP,GAAQA,EAAK,SAAS,GAAG,EAAI,WAAa,OAGjDQ,EADH,CAAC,GAAGF,EAAI,KAAK,iBAAiB,QAAQC,CAAI,KAAKP,CAAI,IAAI,CAAC,EAExD,IAAKS,GACGA,EAAE,OACV,EACA,KAAK,IAAI,EACL,OAAAD,EAAK,OAASA,EAAO,EAC9B,CCHO,SAASE,EAAYV,EAAc,CACjC,OAAAD,EAAYC,CAAI,EAAE,QAAQ,YAAcW,GAAMA,EAAE,CAAC,EAAE,YAAa,EACzE,iMCca,IAAAC,EAAN,cAAyBC,CAAW,CAApC,kCA0DG,oBAAkBC,GACjBA,EAAM,KAAK,MAAM,GAAG,EAAE,CAAC,EAGhC,2BAAyBC,GAAkB,CACzC,MAAMC,EAAS,GACV,OAAAD,EAAA,QAASE,GAAS,CACf,MAAAC,EAAiB,KAAK,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,EAAmB,CACvC,MAAAuB,EAAmB,SAAS,cAAc,KAAK,EAC/CC,EAAiB,SAAS,cAAc,KAAK,EAC7CC,EAAa,SAAS,cAAc,aAAa,EAExCD,EAAA,UAAU,IAAI,OAAO,EACpCA,EAAe,YAAYC,CAAU,EAEpBF,EAAA,aAAa,KAAM,SAAS,EAC7CA,EAAiB,YAAYC,CAAc,EAC3CxB,EAAK,MAAMuB,CAAgB,CAC7B,CAEQ,kBAAkBvB,EAAmB,CAC3C,MAAM0B,EAAW1B,EAAK,UACjBA,EAAA,UAAY,sBAAsB0B,CAAQ,QACjD,CAIQ,0BAA2B,CAC3B,MAAAC,EAAW5D,EAAY,UAAU,EACnC4D,GAAqBhE,EAAA,SAAS,KAAMgE,CAAQ,EAC1C,MAAAC,EAAQ7D,EAAY,OAAO,EAC7B6D,GAAkBjE,EAAA,SAAS,KAAMiE,CAAK,CAC5C,CA+BF,EAEC,gBAAkB,CACX,MAAAvB,EAAe,IAAIlB,EACnB4B,EAAiB,IAAIX,EAAeC,CAAY,EAEtD,MADa,IAAIS,EAAKC,EAAgBV,CAAY,EACvC,MACb,GAAG","names":["toClassName","name","addClasses","element","classes","c","getMetadata","doc","attr","meta","m","toCamelCase","g","SidebarNav","LitElement","entry","data","groups","item","firstLevelPath","group","sitemap","items","html","__decorateClass","customElement","BlockService","block","config","row","cols","col","value","as","a","imgs","img","ps","p","main","shortBlockName","blockWrapper","section","SectionService","blockService","container","sectionMeta","key","style","wrappers","defaultContent","e","wrapper","Main","sectionService","body","components","blocks","component","componentModule","scriptEl","error","sidebarContainer","innerContainer","sidebarNav","children","template","theme"],"sources":["../../src/utils/toClassName.ts","../../src/utils/addClasses.ts","../../src/utils/getMetadata.ts","../../src/utils/toCamelCase.ts","../../src/components/sidebarNav.ts","../../src/main.ts"],"sourcesContent":["export function toClassName(name: string) {\n return typeof name === 'string'\n ? name\n .toLowerCase()\n .replace(/[^0-9a-z]/gi, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n : '';\n}\n","import { toClassName } from './toClassName';\n\nexport const addClasses = (element: HTMLElement, classes: string) => {\n classes.split(',').forEach((c) => {\n element.classList.add(toClassName(c.trim()));\n });\n};\n","export function getMetadata(name: string, doc = document) {\n const attr = name && name.includes(':') ? 'property' : 'name';\n const metaTags: HTMLMetaElement[] =\n ([...doc.head.querySelectorAll(`meta[${attr}=\"${name}\"]`)] as HTMLMetaElement[]) || [];\n const meta = metaTags\n .map((m) => {\n return m.content;\n })\n .join(', ');\n return meta.length ? meta : '';\n}\n","import { toClassName } from './toClassName';\n\n/**\n * Sanitizes a string for use as a js property name.\n * @param {string} name The unsanitized string\n * @returns {string} The camelCased name\n */\nexport function toCamelCase(name: string) {\n return toClassName(name).replace(/-([a-z])/g, (g) => g[1].toUpperCase());\n}\n","import { html, LitElement } from 'lit';\nimport { customElement } from 'lit/decorators.js';\n\ntype SiteMapEntry = {\n path: string;\n title: string;\n description: string;\n lastModified: string; // Assuming this is a string representing a timestamp\n image: string;\n imagealt: string;\n navtitle: string;\n 'nav-test': string;\n imageAlt: string;\n};\n\ntype MenuItem = {\n path: string;\n navtitle: string;\n};\n\ntype Sitemap = SiteMapEntry[];\n\n@customElement('sidebar-nav')\nexport class SidebarNav extends LitElement {\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n async connectedCallback() {\n super.connectedCallback();\n const sitemap = await this.fetchSitemap();\n const items = this.groupByFirstLevelPath(sitemap);\n console.log('navItems', items);\n }\n\n render() {\n return html` `;\n }\n\n private renderMenuItems() {\n return html` `;\n }\n\n private async fetchSitemap(): Promise {\n const response = await fetch(`${window.hlx.codeBasePath}/query-index.json`);\n const json = await response.json();\n return json.data;\n }\n\n private getSubmenuName = (entry: SiteMapEntry) => {\n return entry.path.split('/')[1];\n };\n\n groupByFirstLevelPath = (data: Sitemap) => {\n const groups = {};\n data.forEach((item) => {\n const firstLevelPath = this.getSubmenuName(item); // Extracting the first level of the path\n if (!groups[firstLevelPath]) {\n groups[firstLevelPath] = [];\n }\n groups[firstLevelPath].push({\n path: item.path,\n navtitle: item.navtitle,\n });\n });\n\n const groupedData = Object.values(groups);\n\n return groupedData.map((group: MenuItem[]) => {\n if (group.length === 1) {\n return group[0];\n }\n\n return {\n navtitle: group[0].path.split('/')[1], // posts\n children: group,\n };\n });\n };\n}\n","// const LCP_BLOCKS: string[] = []; // add your LCP blocks to the list\n\nimport { addClasses } from '../src/utils/addClasses';\nimport { getMetadata } from '../src/utils/getMetadata';\nimport { toCamelCase } from '../src/utils/toCamelCase';\nimport { toClassName } from '../src/utils/toClassName';\nimport './components/sidebarNav.ts'\n\ntype ComponentMapping = {\n name: string;\n element: HTMLDivElement;\n};\n\nclass BlockService {\n //TODO: Provider for fetch data\n\n /**\n * Extracts the config from a block.\n * @param {Element} block The block element\n * @returns {object} The block config\n */\n readBlockConfig(block: Element): Record {\n const config: Record = {};\n block.querySelectorAll(':scope > div').forEach((row) => {\n if (row.children) {\n const cols = [...row.children];\n if (cols[1]) {\n const col = cols[1];\n const name = toClassName(cols[0].textContent ?? '');\n let value: any = '';\n if (col.querySelector('a')) {\n const as = [...col.querySelectorAll('a')];\n if (as.length === 1) {\n value = as[0].href;\n } else {\n value = as.map((a) => a.href);\n }\n } else if (col.querySelector('img')) {\n const imgs = [...col.querySelectorAll('img')];\n if (imgs.length === 1) {\n value = imgs[0].src;\n } else {\n value = imgs.map((img) => img.src);\n }\n } else if (col.querySelector('p')) {\n const ps = [...col.querySelectorAll('p')];\n if (ps.length === 1) {\n value = ps[0].textContent;\n } else {\n value = ps.map((p) => p.textContent);\n }\n } else value = row.children[1].textContent;\n config[name] = value;\n }\n }\n });\n return config;\n }\n\n /**\n * Decorates all blocks in a container element.\n * @param {Element} main The container element\n */\n decorateBlocks(main: HTMLElement) {\n main.querySelectorAll('div.section > div > div').forEach(this.decorateBlock);\n }\n\n /**\n * Decorates a block.\n * @param {Element} block The block element\n */\n private decorateBlock(block: HTMLElement) {\n const shortBlockName = block.classList[0];\n if (shortBlockName) {\n block.classList.add('block');\n block.dataset.blockName = shortBlockName;\n const blockWrapper = block.parentElement;\n blockWrapper?.classList.add(`${shortBlockName}-wrapper`);\n const section = block.closest('.section');\n if (section) section.classList.add(`${shortBlockName}-container`);\n }\n }\n}\n\nclass SectionService {\n constructor(private blockService: BlockService) {}\n\n init(container: HTMLElement) {\n this.transformSection(container);\n }\n\n /**\n * Decorates all sections in a container element.\n * @param {Element} main The container element\n */\n private transformSection(main: HTMLElement) {\n main.querySelectorAll(':scope > div').forEach((section) => {\n this.adjustMarkup(section);\n this.processSectionMetaData(section);\n });\n }\n\n private processSectionMetaData(section: HTMLElement) {\n // Process section metadata\n const sectionMeta = section.querySelector('div.section-metadata');\n if (sectionMeta) {\n const meta = this.blockService.readBlockConfig(sectionMeta);\n Object.keys(meta).forEach((key) => {\n if (key === 'style') {\n const styles = meta.style\n .split(',')\n .filter((style: string) => style)\n .map((style: string) => toClassName(style.trim()));\n styles.forEach((style: string) => section.classList.add(style));\n } else {\n section.dataset[toCamelCase(key)] = meta[key];\n }\n });\n if (sectionMeta.parentElement) sectionMeta.parentElement.remove();\n }\n }\n\n private adjustMarkup(section: HTMLDivElement) {\n const wrappers: HTMLDivElement[] = [];\n let defaultContent = false;\n [...section.children].forEach((e) => {\n if (e.tagName === 'DIV' || !defaultContent) {\n const wrapper = document.createElement('div');\n wrappers.push(wrapper);\n defaultContent = e.tagName !== 'DIV';\n if (defaultContent) wrapper.classList.add('default-content-wrapper');\n }\n wrappers[wrappers.length - 1].append(e);\n });\n wrappers.forEach((wrapper) => section.append(wrapper));\n section.classList.add('section');\n section.dataset.sectionStatus = 'initialized';\n section.style.display = 'none';\n }\n}\n\nclass Main {\n constructor(\n private sectionService: SectionService,\n private blockService: BlockService\n ) {}\n\n init = async () => {\n this.setup();\n await this.loadEager();\n };\n\n /**\n * Setup block utils.\n */\n private setup() {\n window.hlx = window.hlx || {};\n window.hlx.RUM_MASK_URL = 'full';\n window.hlx.codeBasePath = '';\n window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on';\n\n const scriptEl = document.querySelector('script[src$=\"/scripts/scripts.js\"]') as HTMLScriptElement;\n if (scriptEl) {\n try {\n [window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js');\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(error);\n }\n }\n }\n\n private loadEager = async () => {\n // TODO: how to support different languages here\n document.documentElement.lang = 'en';\n this.decorateTemplateAndTheme();\n if (document) {\n const body = document.querySelector('body');\n if (body) {\n body.style.display = 'none';\n }\n }\n const main = document.querySelector('main');\n if (main) {\n main.setAttribute('id', 'main');\n this.addSidebarContainer(main);\n this.sectionService.init(main);\n this.addInnerContainer(main); // TODO refactor initializing\n this.blockService.decorateBlocks(main);\n await this.loadComponents();\n // TODO: Performace adjustment\n setTimeout(() => {\n document.body.removeAttribute('style');\n }, 200);\n\n // await this.waitForLCP(LCP_BLOCKS);\n }\n };\n\n private addSidebarContainer(main: HTMLElement) {\n const sidebarContainer = document.createElement('div');\n const innerContainer = document.createElement('div');\n const sidebarNav = document.createElement('sidebar-nav');\n\n innerContainer.classList.add('inner');\n innerContainer.appendChild(sidebarNav);\n\n sidebarContainer.setAttribute('id', 'sidebar');\n sidebarContainer.appendChild(innerContainer)\n main.after(sidebarContainer);\n }\n\n private addInnerContainer(main: HTMLElement) {\n const children = main.innerHTML;\n main.innerHTML = `
    ${children}
    `;\n }\n\n // private loadLazy = async () => {};\n\n private decorateTemplateAndTheme() {\n const template = getMetadata('template');\n if (template) addClasses(document.body, template);\n const theme = getMetadata('theme');\n if (theme) addClasses(document.body, theme);\n }\n\n private loadComponents = async () => {\n const sections = document.querySelectorAll('.section');\n sections.forEach((section) => {\n const components: ComponentMapping[] = [];\n const blocks = section.querySelectorAll('[data-block-name]');\n if (!blocks.length) {\n section.style.removeProperty('display');\n return;\n }\n blocks.forEach((block: HTMLDivElement) => {\n block.style.display = 'none';\n components.push({\n name: block.dataset['blockName'] as string,\n element: block,\n });\n });\n if (components.length) {\n components.forEach(async (component) => {\n const componentModule = await import(\n `${window.hlx.codeBasePath}/dist/${component.name}/${component.name}.js`\n );\n if (componentModule.default) {\n await componentModule.default(component.element);\n }\n });\n }\n section.style.removeProperty('display');\n });\n };\n}\n\n(async function () {\n const blockService = new BlockService();\n const sectionService = new SectionService(blockService);\n const main = new Main(sectionService, blockService);\n await main.init();\n})();\n\n// /**\n// * Loads JS and CSS for a block.\n// * @param {Element} block The block element\n// */\n// async function loadBlock(block) {\n// const status = block.dataset.blockStatus;\n// if (status !== 'loading' && status !== 'loaded') {\n// block.dataset.blockStatus = 'loading';\n// const { blockName } = block.dataset;\n// try {\n// const cssLoaded = loadCSS(`${window.hlx.codeBasePath}/blocks/${blockName}/${blockName}.css`);\n// const decorationComplete = new Promise((resolve) => {\n// (async () => {\n// try {\n// const mod = await import(`${window.hlx.codeBasePath}/blocks/${blockName}/${blockName}.js`);\n// if (mod.default) {\n// await mod.default(block);\n// }\n// } catch (error) {\n// // eslint-disable-next-line no-console\n// console.log(`failed to load module for ${blockName}`, error);\n// }\n// resolve();\n// })();\n// });\n// await Promise.all([cssLoaded, decorationComplete]);\n// } catch (error) {\n// // eslint-disable-next-line no-console\n// console.log(`failed to load block ${blockName}`, error);\n// }\n// block.dataset.blockStatus = 'loaded';\n// }\n// return block;\n// }\n\ndeclare global {\n interface Window {\n hlx: {\n RUM_MASK_URL: string;\n codeBasePath: string;\n lighthouse: boolean;\n };\n }\n}\n"],"file":"main/main.js"} \ No newline at end of file +{"version":3,"mappings":"giCAAO,SAASA,EAAYC,EAAc,CACxC,OAAO,OAAOA,GAAS,SACnBA,EACG,cACA,QAAQ,cAAe,GAAG,EAC1B,QAAQ,MAAO,GAAG,EAClB,QAAQ,SAAU,EAAE,EACvB,EACN,CCNa,MAAAC,EAAa,CAACC,EAAsBC,IAAoB,CACnEA,EAAQ,MAAM,GAAG,EAAE,QAASC,GAAM,CAChCF,EAAQ,UAAU,IAAI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AC/EC,EAAO,CAEd,QAAQ,IAAIA,CAAK,CACnB,CAEJ,CA6BQ,oBAAoBtB,EAAmB,CACvC,MAAAuB,EAAmB,SAAS,cAAc,KAAK,EAC/CC,EAAiB,SAAS,cAAc,KAAK,EAC7CC,EAAa,SAAS,cAAc,aAAa,EAExCD,EAAA,UAAU,IAAI,OAAO,EACpCA,EAAe,YAAYC,CAAU,EAEpBF,EAAA,aAAa,KAAM,SAAS,EAC7CA,EAAiB,YAAYC,CAAc,EAC3CxB,EAAK,MAAMuB,CAAgB,CAC7B,CAEQ,kBAAkBvB,EAAmB,CAC3C,MAAM0B,EAAW1B,EAAK,UACjBA,EAAA,UAAY,sBAAsB0B,CAAQ,QACjD,CAIQ,0BAA2B,CAC3B,MAAAC,EAAWhE,EAAY,UAAU,EACnCgE,GAAqBpE,EAAA,SAAS,KAAMoE,CAAQ,EAC1C,MAAAC,EAAQjE,EAAY,OAAO,EAC7BiE,GAAkBrE,EAAA,SAAS,KAAMqE,CAAK,CAC5C,CA+BF,EAEC,gBAAkB,CACX,MAAAvB,EAAe,IAAIlB,EACnB4B,EAAiB,IAAIX,EAAeC,CAAY,EAEtD,MADa,IAAIS,EAAKC,EAAgBV,CAAY,EACvC,MACb,GAAG","names":["toClassName","name","addClasses","element","classes","c","getMetadata","doc","attr","meta","m","toCamelCase","g","r","t","SidebarNav","LitElement","entry","data","groups","item","firstLevelPath","group","sitemap","html","target","child","__decorateClass","state","customElement","BlockService","block","config","row","cols","col","value","as","a","imgs","img","ps","p","main","shortBlockName","blockWrapper","section","SectionService","blockService","container","sectionMeta","key","style","wrappers","defaultContent","e","wrapper","Main","sectionService","body","components","blocks","component","componentModule","scriptEl","error","sidebarContainer","innerContainer","sidebarNav","children","template","theme"],"sources":["../../src/utils/toClassName.ts","../../src/utils/addClasses.ts","../../src/utils/getMetadata.ts","../../src/utils/toCamelCase.ts","../../node_modules/@lit/reactive-element/decorators/state.js","../../src/components/sidebarNav.ts","../../src/main.ts"],"sourcesContent":["export function toClassName(name: string) {\n return typeof name === 'string'\n ? name\n .toLowerCase()\n .replace(/[^0-9a-z]/gi, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n : '';\n}\n","import { toClassName } from './toClassName';\n\nexport const addClasses = (element: HTMLElement, classes: string) => {\n classes.split(',').forEach((c) => {\n element.classList.add(toClassName(c.trim()));\n });\n};\n","export function getMetadata(name: string, doc = document) {\n const attr = name && name.includes(':') ? 'property' : 'name';\n const metaTags: HTMLMetaElement[] =\n ([...doc.head.querySelectorAll(`meta[${attr}=\"${name}\"]`)] as HTMLMetaElement[]) || [];\n const meta = metaTags\n .map((m) => {\n return m.content;\n })\n .join(', ');\n return meta.length ? meta : '';\n}\n","import { toClassName } from './toClassName';\n\n/**\n * Sanitizes a string for use as a js property name.\n * @param {string} name The unsanitized string\n * @returns {string} The camelCased name\n */\nexport function toCamelCase(name: string) {\n return toClassName(name).replace(/-([a-z])/g, (g) => g[1].toUpperCase());\n}\n","import{property as t}from\"./property.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */function r(r){return t({...r,state:!0,attribute:!1})}export{r as state};\n//# sourceMappingURL=state.js.map\n","import { html, LitElement } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\n\ntype SiteMapEntry = {\n path: string;\n title: string;\n description: string;\n lastModified: string; // Assuming this is a string representing a timestamp\n image: string;\n imagealt: string;\n navtitle: string;\n 'nav-test': string;\n imageAlt: string;\n};\n\ninterface SubMenuItem {\n path: string;\n navtitle: string;\n}\n\ninterface MenuItem {\n path: string;\n navtitle: string;\n children?: SubMenuItem[];\n}\n\ntype Sitemap = SiteMapEntry[];\n\n@customElement('sidebar-nav')\nexport class SidebarNav extends LitElement {\n @state()\n items: MenuItem[];\n\n protected createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n async firstUpdated() {\n const sitemap = await this.fetchSitemap();\n this.items = this.groupByFirstLevelPath(sitemap);\n }\n\n render() {\n if (!this.items) return;\n return html` `;\n }\n\n private renderSubMenu(item) {\n return html` target.classList.toggle('active')}\" class=\"opener\"\n >${item.navtitle}\n `;\n }\n\n private renderMenuItem(item) {\n return html`
  • \n ${item.children !== undefined ? this.renderSubMenu(item) : html`${item.navtitle}`}\n
  • `;\n }\n\n private renderMenuItems() {\n return html`
      \n ${this.items.map((item) => this.renderMenuItem(item))}\n
    `;\n }\n\n private async fetchSitemap(): Promise {\n const response = await fetch(`${window.hlx.codeBasePath}/query-index.json`);\n const json = await response.json();\n return json.data;\n }\n\n private getSubmenuName = (entry: SiteMapEntry) => {\n return entry.path.split('/')[1];\n };\n\n private getNavTitle(item: SiteMapEntry) {\n if (item.path === '/') return 'Homepage';\n return item.navtitle || item.title;\n }\n\n groupByFirstLevelPath = (data: Sitemap) => {\n const groups = {};\n data.forEach((item) => {\n const firstLevelPath = this.getSubmenuName(item); // Extracting the first level of the path\n if (!groups[firstLevelPath]) {\n groups[firstLevelPath] = [];\n }\n groups[firstLevelPath].push({\n path: item.path,\n navtitle: this.getNavTitle(item),\n });\n });\n\n const groupedData = Object.values(groups);\n\n return groupedData.map((group: MenuItem[]) => {\n if (group.length === 1) {\n return group[0];\n }\n\n return {\n navtitle: group[0].path.split('/')[1],\n path: group[0].path,\n children: group,\n };\n });\n };\n}\n","// const LCP_BLOCKS: string[] = []; // add your LCP blocks to the list\n\nimport { addClasses } from '../src/utils/addClasses';\nimport { getMetadata } from '../src/utils/getMetadata';\nimport { toCamelCase } from '../src/utils/toCamelCase';\nimport { toClassName } from '../src/utils/toClassName';\nimport './components/sidebarNav.ts'\n\ntype ComponentMapping = {\n name: string;\n element: HTMLDivElement;\n};\n\nclass BlockService {\n //TODO: Provider for fetch data\n\n /**\n * Extracts the config from a block.\n * @param {Element} block The block element\n * @returns {object} The block config\n */\n readBlockConfig(block: Element): Record {\n const config: Record = {};\n block.querySelectorAll(':scope > div').forEach((row) => {\n if (row.children) {\n const cols = [...row.children];\n if (cols[1]) {\n const col = cols[1];\n const name = toClassName(cols[0].textContent ?? '');\n let value: any = '';\n if (col.querySelector('a')) {\n const as = [...col.querySelectorAll('a')];\n if (as.length === 1) {\n value = as[0].href;\n } else {\n value = as.map((a) => a.href);\n }\n } else if (col.querySelector('img')) {\n const imgs = [...col.querySelectorAll('img')];\n if (imgs.length === 1) {\n value = imgs[0].src;\n } else {\n value = imgs.map((img) => img.src);\n }\n } else if (col.querySelector('p')) {\n const ps = [...col.querySelectorAll('p')];\n if (ps.length === 1) {\n value = ps[0].textContent;\n } else {\n value = ps.map((p) => p.textContent);\n }\n } else value = row.children[1].textContent;\n config[name] = value;\n }\n }\n });\n return config;\n }\n\n /**\n * Decorates all blocks in a container element.\n * @param {Element} main The container element\n */\n decorateBlocks(main: HTMLElement) {\n main.querySelectorAll('div.section > div > div').forEach(this.decorateBlock);\n }\n\n /**\n * Decorates a block.\n * @param {Element} block The block element\n */\n private decorateBlock(block: HTMLElement) {\n const shortBlockName = block.classList[0];\n if (shortBlockName) {\n block.classList.add('block');\n block.dataset.blockName = shortBlockName;\n const blockWrapper = block.parentElement;\n blockWrapper?.classList.add(`${shortBlockName}-wrapper`);\n const section = block.closest('.section');\n if (section) section.classList.add(`${shortBlockName}-container`);\n }\n }\n}\n\nclass SectionService {\n constructor(private blockService: BlockService) {}\n\n init(container: HTMLElement) {\n this.transformSection(container);\n }\n\n /**\n * Decorates all sections in a container element.\n * @param {Element} main The container element\n */\n private transformSection(main: HTMLElement) {\n main.querySelectorAll(':scope > div').forEach((section) => {\n this.adjustMarkup(section);\n this.processSectionMetaData(section);\n });\n }\n\n private processSectionMetaData(section: HTMLElement) {\n // Process section metadata\n const sectionMeta = section.querySelector('div.section-metadata');\n if (sectionMeta) {\n const meta = this.blockService.readBlockConfig(sectionMeta);\n Object.keys(meta).forEach((key) => {\n if (key === 'style') {\n const styles = meta.style\n .split(',')\n .filter((style: string) => style)\n .map((style: string) => toClassName(style.trim()));\n styles.forEach((style: string) => section.classList.add(style));\n } else {\n section.dataset[toCamelCase(key)] = meta[key];\n }\n });\n if (sectionMeta.parentElement) sectionMeta.parentElement.remove();\n }\n }\n\n private adjustMarkup(section: HTMLDivElement) {\n const wrappers: HTMLDivElement[] = [];\n let defaultContent = false;\n [...section.children].forEach((e) => {\n if (e.tagName === 'DIV' || !defaultContent) {\n const wrapper = document.createElement('div');\n wrappers.push(wrapper);\n defaultContent = e.tagName !== 'DIV';\n if (defaultContent) wrapper.classList.add('default-content-wrapper');\n }\n wrappers[wrappers.length - 1].append(e);\n });\n wrappers.forEach((wrapper) => section.append(wrapper));\n section.classList.add('section');\n section.dataset.sectionStatus = 'initialized';\n section.style.display = 'none';\n }\n}\n\nclass Main {\n constructor(\n private sectionService: SectionService,\n private blockService: BlockService\n ) {}\n\n init = async () => {\n this.setup();\n await this.loadEager();\n };\n\n /**\n * Setup block utils.\n */\n private setup() {\n window.hlx = window.hlx || {};\n window.hlx.RUM_MASK_URL = 'full';\n window.hlx.codeBasePath = '';\n window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on';\n\n const scriptEl = document.querySelector('script[src$=\"/scripts/scripts.js\"]') as HTMLScriptElement;\n if (scriptEl) {\n try {\n [window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js');\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(error);\n }\n }\n }\n\n private loadEager = async () => {\n // TODO: how to support different languages here\n document.documentElement.lang = 'en';\n this.decorateTemplateAndTheme();\n if (document) {\n const body = document.querySelector('body');\n if (body) {\n body.style.display = 'none';\n }\n }\n const main = document.querySelector('main');\n if (main) {\n main.setAttribute('id', 'main');\n this.addSidebarContainer(main);\n this.sectionService.init(main);\n this.addInnerContainer(main); // TODO refactor initializing\n this.blockService.decorateBlocks(main);\n await this.loadComponents();\n // TODO: Performace adjustment\n setTimeout(() => {\n document.body.removeAttribute('style');\n }, 200);\n\n // await this.waitForLCP(LCP_BLOCKS);\n }\n };\n\n private addSidebarContainer(main: HTMLElement) {\n const sidebarContainer = document.createElement('div');\n const innerContainer = document.createElement('div');\n const sidebarNav = document.createElement('sidebar-nav');\n\n innerContainer.classList.add('inner');\n innerContainer.appendChild(sidebarNav);\n\n sidebarContainer.setAttribute('id', 'sidebar');\n sidebarContainer.appendChild(innerContainer)\n main.after(sidebarContainer);\n }\n\n private addInnerContainer(main: HTMLElement) {\n const children = main.innerHTML;\n main.innerHTML = `
    ${children}
    `;\n }\n\n // private loadLazy = async () => {};\n\n private decorateTemplateAndTheme() {\n const template = getMetadata('template');\n if (template) addClasses(document.body, template);\n const theme = getMetadata('theme');\n if (theme) addClasses(document.body, theme);\n }\n\n private loadComponents = async () => {\n const sections = document.querySelectorAll('.section');\n sections.forEach((section) => {\n const components: ComponentMapping[] = [];\n const blocks = section.querySelectorAll('[data-block-name]');\n if (!blocks.length) {\n section.style.removeProperty('display');\n return;\n }\n blocks.forEach((block: HTMLDivElement) => {\n block.style.display = 'none';\n components.push({\n name: block.dataset['blockName'] as string,\n element: block,\n });\n });\n if (components.length) {\n components.forEach(async (component) => {\n const componentModule = await import(\n `${window.hlx.codeBasePath}/dist/${component.name}/${component.name}.js`\n );\n if (componentModule.default) {\n await componentModule.default(component.element);\n }\n });\n }\n section.style.removeProperty('display');\n });\n };\n}\n\n(async function () {\n const blockService = new BlockService();\n const sectionService = new SectionService(blockService);\n const main = new Main(sectionService, blockService);\n await main.init();\n})();\n\n// /**\n// * Loads JS and CSS for a block.\n// * @param {Element} block The block element\n// */\n// async function loadBlock(block) {\n// const status = block.dataset.blockStatus;\n// if (status !== 'loading' && status !== 'loaded') {\n// block.dataset.blockStatus = 'loading';\n// const { blockName } = block.dataset;\n// try {\n// const cssLoaded = loadCSS(`${window.hlx.codeBasePath}/blocks/${blockName}/${blockName}.css`);\n// const decorationComplete = new Promise((resolve) => {\n// (async () => {\n// try {\n// const mod = await import(`${window.hlx.codeBasePath}/blocks/${blockName}/${blockName}.js`);\n// if (mod.default) {\n// await mod.default(block);\n// }\n// } catch (error) {\n// // eslint-disable-next-line no-console\n// console.log(`failed to load module for ${blockName}`, error);\n// }\n// resolve();\n// })();\n// });\n// await Promise.all([cssLoaded, decorationComplete]);\n// } catch (error) {\n// // eslint-disable-next-line no-console\n// console.log(`failed to load block ${blockName}`, error);\n// }\n// block.dataset.blockStatus = 'loaded';\n// }\n// return block;\n// }\n\ndeclare global {\n interface Window {\n hlx: {\n RUM_MASK_URL: string;\n codeBasePath: string;\n lighthouse: boolean;\n };\n }\n}\n"],"file":"main/main.js"} \ No newline at end of file diff --git a/src/components/sidebarNav.ts b/src/components/sidebarNav.ts index e2d83955..507f998b 100644 --- a/src/components/sidebarNav.ts +++ b/src/components/sidebarNav.ts @@ -1,5 +1,5 @@ import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import { customElement, state } from 'lit/decorators.js'; type SiteMapEntry = { path: string; @@ -13,27 +13,35 @@ type SiteMapEntry = { imageAlt: string; }; -type MenuItem = { +interface SubMenuItem { path: string; navtitle: string; -}; +} + +interface MenuItem { + path: string; + navtitle: string; + children?: SubMenuItem[]; +} type Sitemap = SiteMapEntry[]; @customElement('sidebar-nav') export class SidebarNav extends LitElement { + @state() + items: MenuItem[]; + protected createRenderRoot(): HTMLElement | DocumentFragment { return this; } - async connectedCallback() { - super.connectedCallback(); + async firstUpdated() { const sitemap = await this.fetchSitemap(); - const items = this.groupByFirstLevelPath(sitemap); - console.log('navItems', items); + this.items = this.groupByFirstLevelPath(sitemap); } render() { + if (!this.items) return; return html` `; } + private renderSubMenu(item) { + return html` ${item.navtitle} + `; + } + + private renderMenuItem(item) { + return html`
  • + ${item.children !== undefined ? this.renderSubMenu(item) : html`${item.navtitle}`} +
  • `; + } + private renderMenuItems() { return html` `; } @@ -83,6 +81,11 @@ export class SidebarNav extends LitElement { return entry.path.split('/')[1]; }; + private getNavTitle(item: SiteMapEntry) { + if (item.path === '/') return 'Homepage'; + return item.navtitle || item.title; + } + groupByFirstLevelPath = (data: Sitemap) => { const groups = {}; data.forEach((item) => { @@ -92,7 +95,7 @@ export class SidebarNav extends LitElement { } groups[firstLevelPath].push({ path: item.path, - navtitle: item.navtitle, + navtitle: this.getNavTitle(item), }); }); @@ -104,7 +107,8 @@ export class SidebarNav extends LitElement { } return { - navtitle: group[0].path.split('/')[1], // posts + navtitle: group[0].path.split('/')[1], + path: group[0].path, children: group, }; }); diff --git a/types/components/sidebarNav.d.ts b/types/components/sidebarNav.d.ts index db9db12c..55b7b984 100644 --- a/types/components/sidebarNav.d.ts +++ b/types/components/sidebarNav.d.ts @@ -10,21 +10,27 @@ type SiteMapEntry = { 'nav-test': string; imageAlt: string; }; -type MenuItem = { +interface SubMenuItem { path: string; navtitle: string; -}; +} +interface MenuItem { + path: string; + navtitle: string; + children?: SubMenuItem[]; +} type Sitemap = SiteMapEntry[]; export declare class SidebarNav extends LitElement { + items: MenuItem[]; protected createRenderRoot(): HTMLElement | DocumentFragment; - connectedCallback(): Promise; - render(): import("lit-html").TemplateResult<1>; + firstUpdated(): Promise; + render(): import("lit-html").TemplateResult<1> | undefined; + private renderSubMenu; + private renderMenuItem; private renderMenuItems; private fetchSitemap; private getSubmenuName; - groupByFirstLevelPath: (data: Sitemap) => (MenuItem | { - navtitle: string; - children: MenuItem[]; - })[]; + private getNavTitle; + groupByFirstLevelPath: (data: Sitemap) => MenuItem[]; } export {};