diff --git a/src/components/d-article.js b/src/components/d-article.js
index e8b12bd..aa9b92f 100644
--- a/src/components/d-article.js
+++ b/src/components/d-article.js
@@ -1,4 +1,4 @@
-import { Template } from '../mixins/template';
+// import { Template } from '../mixins/template';
import { Controller } from '../controller';
const isOnlyWhitespace = /^\s*$/;
@@ -31,7 +31,7 @@ export class Article extends HTMLElement {
connectedCallback() {
document.onreadystatechange = function () {
- console.log("onreadystatechange:");
+ console.log('onreadystatechange:');
console.log(document.readyState);
};
console.info('Article tag connected, we can now listen to controller events.');
diff --git a/src/components/d-bibliography.js b/src/components/d-bibliography.js
index b737228..a420422 100644
--- a/src/components/d-bibliography.js
+++ b/src/components/d-bibliography.js
@@ -35,6 +35,12 @@ export class Bibliography extends HTMLElement {
observer.observe(this, options);
}
+ connectedCallback() {
+ requestAnimationFrame(() => {
+ this.parseIfPossible();
+ });
+ }
+
parseIfPossible() {
const scriptTag = this.querySelector('script');
if (!scriptTag) return;
diff --git a/src/components/d-cite.js b/src/components/d-cite.js
index 13d1cc0..78f1128 100644
--- a/src/components/d-cite.js
+++ b/src/components/d-cite.js
@@ -49,12 +49,6 @@ export class Cite extends T(HTMLElement) {
/* Lifecycle */
- // constructor() {
- // super();
- // // Cite.currentId += 1;
- // // this.citeId = Cite.currentId;
- // }
-
connectedCallback() {
this.outerSpan = this.root.querySelector('#citation-');
this.innerSpan = this.root.querySelector('.citation-number');
@@ -105,11 +99,15 @@ export class Cite extends T(HTMLElement) {
return index == -1 ? '?' : index + 1 + '';
});
const textContent = '[' + numberStrings.join(', ') + ']';
- this.innerSpan.textContent = textContent;
+ if (this.innerSpan) {
+ this.innerSpan.textContent = textContent;
+ }
}
set entries(entries) {
- this.hoverBox.innerHTML = entries.map(hover_cite).join('
');
+ if (this.hoverBox) {
+ this.hoverBox.innerHTML = entries.map(hover_cite).join('
');
+ }
}
}
diff --git a/src/controller.js b/src/controller.js
index cec5244..d715e67 100644
--- a/src/controller.js
+++ b/src/controller.js
@@ -38,7 +38,7 @@ export const Controller = {
citeTag.entries = entries;
},
- onCiteKeyChanged(event) {
+ onCiteKeyChanged() {
// const [citeTag, keys] = event.detail;
// update citations
@@ -145,7 +145,7 @@ export const Controller = {
return;
} else {
Controller.loaded = true;
- console.log('Controller running DOMContentLoaded')
+ console.log('Controller running DOMContentLoaded');
}
const frontMatterTag = document.querySelector('d-front-matter');
diff --git a/src/transforms/meta.js b/src/transforms/meta.js
index a02231d..cad5c56 100644
--- a/src/transforms/meta.js
+++ b/src/transforms/meta.js
@@ -37,6 +37,11 @@ export default function(dom, data) {
+ `);
+ }
+
+ if (data.updatedDate) {
+ appendHead(`
`);
}
diff --git a/src/transforms/polyfills.js b/src/transforms/polyfills.js
index 34ded4d..d4fb6c5 100644
--- a/src/transforms/polyfills.js
+++ b/src/transforms/polyfills.js
@@ -1,47 +1,74 @@
const webcomponentPath = 'https://distill.pub/third-party/polyfills/webcomponents-lite.js';
const intersectionObserverPath = 'https://distill.pub/third-party/polyfills/intersection-observer.js';
-const template = `
-if ('IntersectionObserver' in window &&
- 'IntersectionObserverEntry' in window &&
- 'intersectionRatio' in IntersectionObserverEntry.prototype) {
- // Platform supports IntersectionObserver natively! :-)
- if (!('isIntersecting' in IntersectionObserverEntry.prototype)) {
- Object.defineProperty(IntersectionObserverEntry.prototype,
- 'isIntersecting', {
- get: function () {
- return this.intersectionRatio > 0;
- }
- });
- }
-} else {
- // Platform does not support webcomponents--loading polyfills synchronously.
- const scriptTag = document.createElement('script');
- scriptTag.src = '${intersectionObserverPath}';
- scriptTag.async = false;
- document.currentScript.parentNode.insertBefore(scriptTag, document.currentScript.nextSibling);
-}
+// const template = `
+// if ('IntersectionObserver' in window &&
+// 'IntersectionObserverEntry' in window &&
+// 'intersectionRatio' in IntersectionObserverEntry.prototype) {
+// // Platform supports IntersectionObserver natively! :-)
+// if (!('isIntersecting' in IntersectionObserverEntry.prototype)) {
+// Object.defineProperty(IntersectionObserverEntry.prototype,
+// 'isIntersecting', {
+// get: function () {
+// return this.intersectionRatio > 0;
+// }
+// });
+// }
+// } else {
+// // Platform does not support webcomponents--loading polyfills synchronously.
+// const scriptTag = document.createElement('script');
+// scriptTag.src = '${intersectionObserverPath}';
+// scriptTag.async = false;
+// document.currentScript.parentNode.insertBefore(scriptTag, document.currentScript.nextSibling);
+// }
+//
+// if ('registerElement' in document &&
+// 'import' in document.createElement('link') &&
+// 'content' in document.createElement('template')) {
+// // Platform supports webcomponents natively! :-)
+// } else {
+// // Platform does not support webcomponents--loading polyfills synchronously.
+// const scriptTag = document.createElement('script');
+// scriptTag.src = '${webcomponentPath}';
+// scriptTag.async = false;
+// document.currentScript.parentNode.insertBefore(scriptTag, document.currentScript.nextSibling);
+// }
+//
+//
+// `;
-if ('registerElement' in document &&
- 'import' in document.createElement('link') &&
- 'content' in document.createElement('template')) {
- // Platform supports webcomponents natively! :-)
-} else {
- // Platform does not support webcomponents--loading polyfills synchronously.
- const scriptTag = document.createElement('script');
- scriptTag.src = '${webcomponentPath}';
- scriptTag.async = false;
- document.currentScript.parentNode.insertBefore(scriptTag, document.currentScript.nextSibling);
-}
+
+const addBackIn = `
+window.addEventListener('WebComponentsReady', function() {
+ console.warn('WebComponentsReady');
+ const loaderTag = document.createElement('script');
+ loaderTag.src = 'http://localhost:8888/dist/template.v2.js';
+ document.head.insertBefore(loaderTag, document.head.firstChild);
+});
`;
export default function render(dom) {
+ // pull out template script tag
+ const templateTag = dom.querySelector('script[src*="template.v2.js"]');
+ templateTag.parentNode.removeChild(templateTag);
+
+ // add loader
+ const loaderTag = dom.createElement('script');
+ loaderTag.src = 'https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.17/webcomponents-loader.js';
+ dom.head.insertBefore(loaderTag, dom.head.firstChild);
+
+ // add loader event listener to add tempalrte back in
+ const addTag = dom.createElement('script');
+ addTag.innerHTML = addBackIn;
+ dom.head.insertBefore(addTag, dom.head.firstChild);
+
+
// create polyfill script tag
- const polyfillScriptTag = dom.createElement('script');
- polyfillScriptTag.innerHTML = template;
- polyfillScriptTag.id = 'polyfills';
+ // const polyfillScriptTag = dom.createElement('script');
+ // polyfillScriptTag.innerHTML = template;
+ // polyfillScriptTag.id = 'polyfills';
// insert at appropriate position--before any other script tag
- const firstScriptTag = dom.head.querySelector('script');
- dom.head.insertBefore(polyfillScriptTag, firstScriptTag);
+ // const firstScriptTag = dom.head.querySelector('script');
+ // dom.head.insertBefore(polyfillScriptTag, firstScriptTag);
}
diff --git a/src/ui/d-slider.js b/src/ui/d-slider.js
index 1b2b421..1cdc3d5 100644
--- a/src/ui/d-slider.js
+++ b/src/ui/d-slider.js
@@ -90,14 +90,14 @@ const T = Template('d-slider', `
-