-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull-citations.js
99 lines (89 loc) · 4.08 KB
/
pull-citations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const fs = require("fs");
const { Cite, plugins } = require("@citation-js/core");
// Load plugins
require("@citation-js/plugin-doi");
require("@citation-js/plugin-csl");
require("@citation-js/plugin-bibtex");
require("@citation-js/plugin-software-formats");
const config = plugins.config.get("@bibtex");
const publications = [
{ doi: "https://doi.org/10.1016/j.jmps.2017.12.007", labels: [] },
{ doi: "https://doi.org/10.1016/j.cemconres.2020.105989", labels: [] },
{ doi: "https://doi.org/10.1016/j.surfcoat.2023.129811", labels: [] },
{ doi: "https://doi.org/10.3390/ma16093397", labels: ["Laue"] },
{ doi: "https://doi.org/10.1088/1361-648X/aca860", labels: [] },
{
doi: "https://doi.org/10.1088/1757-899X/580/1/012018",
labels: ["HEDM"],
},
{ doi: "https://doi.org/10.1007/s40192-022-00281-4", labels: [] },
{ doi: "https://doi.org/10.56952/ARMA-2023-0958", labels: [] },
{ doi: "https://doi.org/10.1016/j.jmps.2020.104192", labels: [] },
{ doi: "https://doi.org/10.1016/j.matchar.2024.114432", labels: [] },
{ doi: "https://doi.org/10.1016/j.ijplas.2024.104076", labels: [] },
{ doi: "https://doi.org/10.1016/j.actamat.2023.119567", labels: [] },
{ doi: "https://doi.org/10.1016/j.actamat.2023.119300", labels: [] },
{ doi: "https://doi.org/10.1016/j.matchar.2023.112692", labels: [] },
{ doi: "https://doi.org/10.1038/s41467-022-33437-z", labels: [] },
{ doi: "https://doi.org/10.1016/j.ijfatigue.2022.107113", labels: [] },
{ doi: "https://doi.org/10.1016/j.actamat.2022.118039", labels: [] },
{ doi: "https://doi.org/10.1016/j.msea.2021.142498", labels: [] },
{ doi: "https://doi.org/10.1016/j.actamat.2021.117120", labels: [] },
{ doi: "https://doi.org/10.1016/j.msea.2021.141034", labels: [] },
{ doi: "https://doi.org/10.1016/j.ijplas.2021.103087", labels: [] },
{ doi: "https://doi.org/10.1016/j.mtla.2021.101063", labels: [] },
{ doi: "https://doi.org/10.1038/s41467-020-16894-2", labels: [] },
{ doi: "https://doi.org/10.1038/s41598-019-54724-8", labels: [] },
{ doi: "https://doi.org/10.1016/j.actamat.2020.05.019", labels: [] },
{
bibtex: `@article{hurley2018characterization,
title={Characterization of the crystal structure, kinematics, stresses and rotations in angular granular quartz during compaction},
author={Hurley, Ryan C and Herbold, Eric B and Pagan, Darren C},
journal={Journal of Applied Crystallography},
volume={51},
number={4},
pages={1021--1034},
year={2018},
publisher={International Union of Crystallography}
}`,
labels: [],
},
{ doi: "https://doi.org/10.1063/5.0161343", labels: [] },
{ doi: "https://doi.org/10.1063/5.0088607", labels: [] },
{ doi: "https://doi.org/10.1063/5.0095654", labels: [] },
{ doi: "https://doi.org/10.1063/5.0072208", labels: ["Powder"] },
];
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function formatCite({ cite, labels }) {
return {
title: cite.data[0].title,
authors: cite.data[0].author
.map((author) => `${author.family}, ${author.given}`)
.join(", "),
abstract: cite.data[0].abstract,
date: cite.data[0].issued["date-parts"][0].join("-"),
link: cite.data[0].URL,
labels,
};
}
function emit(file, citations) {
source = `
/** This file was generated by pull-citations.js */
export let publications = ${JSON.stringify(citations, null, 2)};
`;
fs.writeFileSync(file, source);
}
async function main() {
const file = "./src/components/.publications.js";
console.log("Emitting publications to ", file);
const citations = [];
for (const { doi, bibtex, labels } of publications) {
// Avoid 429s
await delay(200);
const cite = await Cite.async(doi || bibtex);
citations.push({ cite, labels });
console.log("Fetched", cite.data[0].title);
}
emit(file, citations.map(formatCite));
}
main();