Skip to content

Commit

Permalink
keywords v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ebarra committed Nov 21, 2024
1 parent e6ee92a commit 7791bf4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/research/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default function Research() {
</div>
<div className="paper_subtitle">
<p>{author}. {journal}</p>
</div>
</div>
</div>
</div>
{doi ? (
Expand Down
2 changes: 1 addition & 1 deletion constants/publications.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion transformPublications.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ fs.readFile("constants/publications.bib", function(err, buf) {
lang: 'en-US',
prepend (entry) {
let {id, issued, DOI, type, title, volume, page, keyword} = entry;
//keyword contains the research lines separated by comma, but sometimes it is empty
if(!keyword){
keyword = "";
}

if (DOI && !DOI.match(/http/)) {
DOI = "https://doi.org/" + DOI;
Expand Down Expand Up @@ -54,7 +58,16 @@ fs.readFile("constants/publications.bib", function(err, buf) {
output = output.replace('<div class="csl-bib-body">',"");
output = output.replace(/,([^,]*)$/,"$1");
output = "["+output+"]";
const str = JSON.parse(output).sort(function(a, b){
//transform keyword from "keyword1,keyword2" to ["keyword1", "keyword2"]
let jsonoutput = JSON.parse(output);
jsonoutput = jsonoutput.map((item) => {
if (item.keyword) {
item.keyword = item.keyword.split(",");
}
return item;
});

const str = jsonoutput.sort(function(a, b){
if (a.date && b.date) {
return b.date[0] - a.date[0]
} else if (a.date) {
Expand Down

0 comments on commit 7791bf4

Please sign in to comment.