Skip to content

Commit f0e0224

Browse files
committed
Web: Add DOI display and citation support to lesson page
- Updated generateCitation to include DOI in APA and BibTeX formats - Added DOI badge to 'Cite this Lesson' card
1 parent 89baa4c commit f0e0224

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/pages/lessons/[slug].astro

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,25 @@ const generateCitation = (l: any) => {
5656
return `${last}, ${first}.`;
5757
}).join(', ') : 'UCLA IMLS Open Science';
5858
59-
const apa = `${authorList} (${year}). ${l.name}. UCLA IMLS Open Science. ${siteConfig.url}/lessons/${slugify(l.name)}`;
59+
let apa = `${authorList} (${year}). ${l.name}. UCLA IMLS Open Science. ${siteConfig.url}/lessons/${slugify(l.name)}`;
60+
if (l.doi) {
61+
apa += ` https://doi.org/${l.doi}`;
62+
}
6063
6164
const bibtexAuthor = l.authors ? l.authors.join(' and ') : 'UCLA IMLS Open Science';
6265
const bibtexId = slugify(l.name).replace(/-/g, '_');
63-
const bibtex = `@misc{${bibtexId}_${year},
66+
let bibtex = `@misc{${bibtexId}_${year},
6467
author = {${bibtexAuthor}},
6568
title = {${l.name}},
6669
year = {${year}},
6770
publisher = {UCLA IMLS Open Science},
68-
url = {${siteConfig.url}/lessons/${slugify(l.name)}}
69-
}`;
71+
url = {${siteConfig.url}/lessons/${slugify(l.name)}}`;
72+
73+
if (l.doi) {
74+
bibtex += `,\n doi = {${l.doi}}`;
75+
}
76+
77+
bibtex += `\n}`;
7078
7179
return { apa, bibtex };
7280
};
@@ -302,6 +310,14 @@ const citation = generateCitation(lesson);
302310
<div class="card border-0 shadow-sm mb-4">
303311
<div class="card-header bg-light font-weight-bold">Cite this Lesson</div>
304312
<div class="card-body">
313+
{lesson.doi && (
314+
<div class="mb-3">
315+
<p class="small text-muted mb-1"><strong>DOI:</strong></p>
316+
<a href={`https://doi.org/${lesson.doi}`} target="_blank" class="badge badge-info p-2" style="font-size: 0.9rem;">
317+
<i class="fas fa-fingerprint mr-1"></i> {lesson.doi}
318+
</a>
319+
</div>
320+
)}
305321
<p class="small text-muted mb-2">APA Format:</p>
306322
<div class="bg-light p-2 rounded mb-3 border text-break small">
307323
{citation.apa}

0 commit comments

Comments
 (0)