with the live content
- for (let node of templates) {
- if (Island.getParents(node, Island.tagName, this).length > 0) {
- continue;
- }
- let value = node.getAttribute(this.attrs.template);
- // get rid of the rest of the content on the island
- if (value === 'replace') {
- let children = Array.from(this.childNodes);
- for (let child of children) {
- this.removeChild(child);
- }
- this.appendChild(node.content);
- break;
- } else {
- if (value === 'once' && node.innerHTML) {
- if (islandOnceCache.has(node.innerHTML)) {
- node.remove();
- return;
- }
-
- islandOnceCache.set(node.innerHTML, true);
- }
-
- node.replaceWith(node.content);
- }
- }
- }
-
- async hydrate() {
- let conditions = [];
- if (this.parentNode) {
- // wait for all parents before hydrating
- conditions.push(Island.ready(this.parentNode));
- }
-
- let attrs = this.getConditions();
- for (let condition in attrs) {
- if (this.conditionMap[condition]) {
- conditions.push(this.conditionMap[condition](attrs[condition], this));
- }
- }
-
- // Loading conditions must finish before dependencies are loaded
- await Promise.all(conditions);
-
- this.replaceTemplates(this.getTemplates());
-
- let mod;
- // [dependency="my-component-code.js"]
- let importScript = this.getAttribute(this.attrs.import);
- if (importScript) {
- // we could resolve import maps here manually but you’d still have to use the full URL in your script’s import anyway
- mod = await import(importScript);
- }
-
- if (mod) {
- // Use `import=""` for when import maps are available e.g. `import="petite-vue"`
- let fn =
- Island.autoinit[this.getAttribute(this.attrs.autoInitType) || importScript];
-
- if (fn) {
- await fn.call(this, mod);
- }
- }
-
- this.readyResolve({
- import: mod
- });
-
- this.setAttribute(this.attrs.ready, '');
- }
-}
-
-class Conditions {
- static visible(noop, el) {
- if (!('IntersectionObserver' in window)) {
- // runs immediately
- return;
- }
-
- return new Promise(resolve => {
- let observer = new IntersectionObserver(entries => {
- let [entry] = entries;
- if (entry.isIntersecting) {
- observer.unobserve(entry.target);
- resolve();
- }
- });
-
- observer.observe(el);
- });
- }
-
- // TODO make sure this runs after all of the conditions have finished, otherwise it will
- // finish way before the other lazy loaded promises and will be the same as a noop when
- // on:interaction or on:visible finishes much later
- static idle() {
- let onload = new Promise(resolve => {
- if (document.readyState !== 'complete') {
- window.addEventListener('load', () => resolve(), {once: true});
- } else {
- resolve();
- }
- });
-
- if (!('requestIdleCallback' in window)) {
- // run immediately
- return onload;
- }
-
- // both idle and onload
- return Promise.all([
- new Promise(resolve => {
- requestIdleCallback(() => {
- resolve();
- });
- }),
- onload
- ]);
- }
-
- static interaction(eventOverrides, el) {
- let events = ['click', 'touchstart'];
- // event overrides e.g. on:interaction="mouseenter"
- if (eventOverrides) {
- events = (eventOverrides || '').split(',').map(entry => entry.trim());
- }
-
- return new Promise(resolve => {
- function resolveFn(e) {
- resolve();
-
- // cleanup the other event handlers
- for (let name of events) {
- el.removeEventListener(name, resolveFn);
- }
- }
-
- for (let name of events) {
- el.addEventListener(name, resolveFn, {once: true});
- }
- });
- }
-
- static media(query) {
- let mm = {
- matches: true
- };
-
- if (query && 'matchMedia' in window) {
- mm = window.matchMedia(query);
- }
-
- if (mm.matches) {
- return;
- }
-
- return new Promise(resolve => {
- mm.addListener(e => {
- if (e.matches) {
- resolve();
- }
- });
- });
- }
-
- static saveData(expects) {
- // return early if API does not exist
- if (
- !('connection' in navigator) ||
- navigator.connection.saveData === (expects !== 'false')
- ) {
- return Promise.resolve();
- }
-
- // dangly promise
- return new Promise(() => {});
- }
-}
-
-// Should this auto define? Folks can redefine later using { component } export
-if ('customElements' in window) {
- window.customElements.define(Island.tagName, Island);
- window.Island = Island;
-}
-
-export const component = Island;
-
-export const ready = Island.ready;
diff --git a/src/pages/github.njk b/src/pages/github.njk
new file mode 100644
index 0000000..bde2fdd
--- /dev/null
+++ b/src/pages/github.njk
@@ -0,0 +1,16 @@
+---
+title: Github
+permalink: /github/index.html
+description: This is just a testing environment
+layout: page
+---
+
+
+ {% for repository in github %}
+ -
+ {{ repository.name }}
+
+ {% else %}
+ - This would display if the 'item' collection were empty
+ {% endfor %}
+
diff --git a/src/pages/test.njk b/src/pages/test.njk
index 4a2e7f1..c290e3c 100644
--- a/src/pages/test.njk
+++ b/src/pages/test.njk
@@ -5,11 +5,23 @@ description: This is just a testing environment
layout: page
---
+Version number {{ meta.pkv }}
+
+
+
+{% renderTemplate "webc" %}
+dsfgdfg
+{% endrenderTemplate %}
+
Icing jelly soufflé shortbread chocolate cake muffin gummies cotton candy lemon drops.
Cake gummi bears dragée chocolate sweet croissant sweet croissant.
+{% renderTemplate "webc" %}
+
+{% endrenderTemplate %}
+
Testing counter
counter inside island, activate on interaction