diff --git a/src/components.js b/src/components.js index 32eb8f0..c8937a1 100644 --- a/src/components.js +++ b/src/components.js @@ -1,3 +1,10 @@ +/* Flag that we're being loaded */ +if (window.distillLoaded) { + throw new Error('Distill Template is getting loaded more than once, aborting!'); +} else { + window.distillLoaded = true; +} + /* Static styles and other modules */ import { makeStyleTag } from './styles/styles'; makeStyleTag(document); @@ -20,8 +27,7 @@ import { References } from './components/d-references'; import { TOC } from './components/d-toc'; import { Figure } from './components/d-figure'; import { Interstitial } from './components/d-interstitial'; - -import { Slider } from './ui/d-slider'; +import { Slider } from './ui/d-slider'; const components = [ Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code, diff --git a/src/components/d-article.js b/src/components/d-article.js index 5085868..d228079 100644 --- a/src/components/d-article.js +++ b/src/components/d-article.js @@ -14,9 +14,6 @@ export class Article extends HTMLElement { for (const mutation of mutations) { for (const addedNode of mutation.addedNodes) { switch (addedNode.nodeName) { - // case 'HR': - // console.warn('Use of
tags in distill articles is discouraged as they interfere with layout! To separate sections, please just use h2 or h3 tags.'); - // break; case '#text': { // usually text nodes are only linebreaks. const text = addedNode.nodeValue; if (!isOnlyWhitespace.test(text)) { diff --git a/src/components/d-bibliography.js b/src/components/d-bibliography.js index 6b6135e..f88bbad 100644 --- a/src/components/d-bibliography.js +++ b/src/components/d-bibliography.js @@ -1,9 +1,16 @@ import { parseBibtex } from '../helpers/bibtex'; export function parseBibliography(element) { - if (element.firstElementChild && element.firstElementChild.tagName === 'SCRIPT') { - const bibtex = element.firstElementChild.textContent; - return parseBibtex(bibtex); + const scriptTag = element.firstElementChild; + if (scriptTag && scriptTag.tagName === 'SCRIPT') { + if (scriptTag.type == 'text/bibtex') { + const bibtex = element.firstElementChild.textContent; + return parseBibtex(bibtex); + } else if (scriptTag.type == 'text/json') { + return new Map(JSON.parse(scriptTag.textContent)); + } else { + console.warn('Unsupported bibliography script tag type: ' + scriptTag.type); + } } } diff --git a/src/components/d-figure.js b/src/components/d-figure.js index 2df9302..a3e1c47 100644 --- a/src/components/d-figure.js +++ b/src/components/d-figure.js @@ -166,7 +166,6 @@ if (typeof window !== 'undefined') { clearTimeout(timeout); timeout = setTimeout(() => { Figure.isScrolling = false; - console.log('Stopped Scrolling') Figure.runReadyQueue(); }, 500); }; diff --git a/src/distill-components/distill-appendix.js b/src/distill-components/distill-appendix.js index 6770b0e..924dedc 100644 --- a/src/distill-components/distill-appendix.js +++ b/src/distill-components/distill-appendix.js @@ -30,21 +30,34 @@ const styles = ` `; export function appendixTemplate(frontMatter) { - return ` - ${styles} + let html = styles; -

Updates and Corrections

-

View all changes to this article since it was first published. If you see mistakes or want to suggest changes, please create an issue on GitHub.

+ if (typeof frontMatter.githubUrl !== 'undefined') { + html += ` +

Updates and Corrections

+

View all changes to this article since it was first published. If you see mistakes or want to suggest changes, please create an issue on GitHub.

+ `; + } -

Reuse

-

Diagrams and text are licensed under Creative Commons Attribution CC-BY 4.0 with the source available on GitHub, unless noted otherwise. The figures that have been reused from other sources don’t fall under this license and can be recognized by a note in their caption: “Figure from …”.

+ const journal = frontMatter.journal; + if (typeof journal !== 'undefined' && journal.title === 'Distill') { + html += ` +

Reuse

+

Diagrams and text are licensed under Creative Commons Attribution CC-BY 4.0 with the source available on GitHub, unless noted otherwise. The figures that have been reused from other sources don’t fall under this license and can be recognized by a note in their caption: “Figure from …”.

+ `; + } -

Citation

-

For attribution in academic contexts, please cite this work as

-
${frontMatter.concatenatedAuthors}, "${frontMatter.title}", Distill, ${frontMatter.publishedYear}.
-

BibTeX citation

-
${serializeFrontmatterToBibtex(frontMatter)}
- `; + if (typeof frontMatter.publishedDate !== 'undefined') { + html += ` +

Citation

+

For attribution in academic contexts, please cite this work as

+
${frontMatter.concatenatedAuthors}, "${frontMatter.title}", Distill, ${frontMatter.publishedYear}.
+

BibTeX citation

+
${serializeFrontmatterToBibtex(frontMatter)}
+ `; + } + + return html; } export class DistillAppendix extends HTMLElement { diff --git a/src/distill-components/distill-header.js b/src/distill-components/distill-header.js index e312543..8e4cb2a 100644 --- a/src/distill-components/distill-header.js +++ b/src/distill-components/distill-header.js @@ -4,80 +4,81 @@ import logo from '../assets/distill-logo.svg'; const T = Template('distill-header', ` - -
+
-
Distill + + - Latest - About - Prize - Submit
-`); +`, false); //