File size: 1,460 Bytes
fee9c1e e0ad823 fee9c1e e0ad823 e329457 e0ad823 | 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 | ---
interface Props {
title: string;
authors?: string[];
affiliation?: string;
published?: string;
}
const { title, authors = [], affiliation, published } = Astro.props as Props;
---
<header class="meta">
<div class="meta-container">
{authors.length > 0 && (
<div class="meta-container-cell">
<h3>Authors</h3>
<p>{authors.join(', ')}</p>
</div>
)}
{affiliation && (
<div class="meta-container-cell">
<h3>Affiliation</h3>
<p>{affiliation}</p>
</div>
)}
{published && (
<div class="meta-container-cell">
<h3>Published</h3>
<p>{published}</p>
</div>
)}
<div class="meta-container-cell">
<h3>PDF</h3>
<p><button id="download-pdf-btn" type="button">Download PDF</button></p>
</div>
</div>
</header>
<script>
// Attach a handler to trigger a programmatic download
(() => {
const ready = () => {
const btn = document.getElementById('download-pdf-btn');
if (!btn) return;
btn.addEventListener('click', () => {
const a = document.createElement('a');
a.href = '/article.pdf';
a.setAttribute('download', 'article.pdf');
document.body.appendChild(a);
a.click();
a.remove();
});
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', ready, { once: true });
} else { ready(); }
})();
</script>
|