fix citation

This commit is contained in:
Christopher Olah
2017-01-08 12:34:19 -08:00
parent b7c7417a57
commit bbfb44bd07
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -8,8 +8,10 @@ export default function(dom, data) {
}
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
console.log(citeTags)
citeTags.forEach(el => {
var keys = el.textContent.split(",");
var keys = el.getAttribute("key").split(",");
console.log(keys)
var cite_string = keys.map(inline_cite).join(", ");
el.innerHTML = cite_string;
});
@@ -26,6 +28,7 @@ export default function(dom, data) {
}
function inline_cite(key){
console.log(key, data.citations)
if (key in data.citations){
var ent = data.citations[key];
var names = ent.author.split(" and ");
+2 -2
View File
@@ -61,7 +61,7 @@
<h2>A description of the article</h2>
<dt-byline></dt-byline>
<p>This is the first paragraph of the article.</p>
<p>We can also cite <dt-cite article="gregor2015draw"></dt-cite> external publications.</p>
<p>We can also cite <dt-cite key="gregor2015draw"></dt-cite> external publications.</p>
</dt-article>
<dt-bibliography>
@article{gregor2015draw,
@@ -137,7 +137,7 @@
</dt-code>
<p>Citations are then used in the article body with the <dt-code language="html">&lt;dt-cite&gt;</dt-code> tag. The <dt-code>article</dt-code> attribute is a reference to the id provided in the bibiography.</p>
<dt-code block language="html">
&lt;dt-cite article="gregor2015draw"&gt;&lt;/dt-cite&gt;
&lt;dt-cite ket="gregor2015draw"&gt;&lt;/dt-cite&gt;
</dt-code>
<hr>