Fix interstitial on localhost, distill-appendix crash on unpublished articles

This commit is contained in:
Ludwig Schubert
2017-10-19 13:44:56 -07:00
parent 02563c32d6
commit 1a4cd694cd
10 changed files with 134 additions and 83 deletions
+10 -6
View File
@@ -9,17 +9,21 @@
export default function(dom, data) {
const article = dom.querySelector('d-article');
if (!article) {
console.warn('No d-article tag found!');
console.warn('No d-article tag found; skipping adding optional components!');
return;
}
const hasPassword = typeof data.password !== 'undefined';
let interstitial = dom.querySelector('d-interstitial');
if (!interstitial && data.password) {
interstitial = dom.createElement('d-interstitial');
interstitial.password = data.password;
dom.body.insertBefore(interstitial, dom.body.firstChild);
if (hasPassword && !interstitial) {
const inBrowser = typeof window !== 'undefined';
const onLocalhost = inBrowser && window.location.hostname.includes('localhost');
if (!inBrowser || !onLocalhost) {
interstitial = dom.createElement('d-interstitial');
interstitial.password = data.password;
dom.body.insertBefore(interstitial, dom.body.firstChild);
}
}
// let h1 = dom.querySelector('h1');