File size: 10,220 Bytes
6afedde |
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
---
interface Props {
citationText: string;
bibtex: string;
licence?: string;
doi?: string;
}
const { citationText, bibtex, licence, doi } = Astro.props as Props;
---
<footer class="footer">
<div class="footer-inner">
<section class="citation-block">
<h3>Citation</h3>
<p>For attribution in academic contexts, please cite this work as</p>
<pre class="citation short">{citationText}</pre>
<p>BibTeX citation</p>
<pre class="citation long">{bibtex}</pre>
</section>
{
doi && (
<section class="doi-block">
<h3>DOI</h3>
<p>
<a
href={`https://doi.org/${doi}`}
target="_blank"
rel="noopener noreferrer"
>
{doi}
</a>
</p>
</section>
)
}
{
licence && (
<section class="reuse-block">
<h3>Reuse</h3>
<p set:html={licence} />
</section>
)
}
<section class="references-block">
<slot />
</section>
<div class="template-credit">
<p>
Made with ❤️ with <a
href="https://huggingface.co/spaces/tfrere/research-article-template"
target="_blank"
rel="noopener noreferrer">research article template</a
>
</p>
</div>
</div>
</footer>
<script is:inline>
(() => {
const getFooter = () =>
document.currentScript?.closest("footer") ||
document.querySelector("footer.footer");
const footer = getFooter();
if (!footer) return;
const target = footer.querySelector(".references-block");
if (!target) return;
const contentRoot =
document.querySelector("section.content-grid main") ||
document.querySelector("main") ||
document.body;
const ensureHeading = (text) => {
const exists = Array.from(target.children).some(
(c) =>
c.tagName === "H3" &&
c.textContent.trim().toLowerCase() === text.toLowerCase(),
);
if (!exists) {
const h = document.createElement("h3");
h.textContent = text;
target.appendChild(h);
}
};
const moveIntoFooter = (element, headingText) => {
if (!element) return false;
// Remove an eventual heading already included inside the block (avoid duplicates)
const firstHeading = element.querySelector(
":scope > h1, :scope > h2, :scope > h3",
);
if (firstHeading) {
const txt = (firstHeading.textContent || "").trim().toLowerCase();
const targetTxt = headingText.trim().toLowerCase();
if (
txt === targetTxt ||
txt.includes("reference") ||
txt.includes("bibliograph")
) {
firstHeading.remove();
}
}
// Move footnote backref links inside paragraphs BEFORE moving element
if (element.classList && element.classList.contains("footnotes")) {
const footnoteItems = element.querySelectorAll("li");
footnoteItems.forEach((item) => {
const backrefContainer = item.querySelector("small.backrefs");
const lastP = item.querySelector("p:last-of-type");
if (backrefContainer && lastP && !lastP.contains(backrefContainer)) {
lastP.appendChild(document.createTextNode(" "));
lastP.appendChild(backrefContainer);
}
});
}
ensureHeading(headingText);
// Move element directly - this preserves KaTeX DOM structure and inline styles
// KaTeX is already rendered at build-time, so we just need to preserve the HTML
target.appendChild(element);
return true;
};
const run = () => {
// Prevent multiple runs
if (footer.dataset.processed === "true") return false;
const findFirstOutsideFooter = (selectors) => {
// Try contentRoot first, then document.body
const searchRoots = [contentRoot, document.body].filter(Boolean);
for (const root of searchRoots) {
for (const sel of selectors) {
const el = root.querySelector(sel);
if (el && !footer.contains(el)) return el;
}
}
return null;
};
const referencesEl = findFirstOutsideFooter([
"#bibliography-references-list",
"[data-bibliography-block]",
"#references",
"#refs",
".references",
".bibliography",
]);
// Try multiple selectors for footnotes
const footnotesEl = findFirstOutsideFooter([
"[data-built-footnotes]",
".footnotes",
"section.footnotes",
"div.footnotes",
]);
const movedRefs = moveIntoFooter(referencesEl, "References");
const movedNotes = moveIntoFooter(footnotesEl, "Footnotes");
if (movedRefs || movedNotes) {
footer.dataset.processed = "true";
}
return movedRefs || movedNotes;
};
// Try multiple times to catch footnotes at different stages
const attemptMove = () => {
run();
};
// Try immediately
attemptMove();
// Try on DOMContentLoaded
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", attemptMove, {
once: true,
});
}
// Try on window load
window.addEventListener(
"load",
() => {
setTimeout(attemptMove, 100);
},
{ once: true },
);
// Final attempt after a short delay
setTimeout(attemptMove, 300);
// Resize on window changes (e.g., fonts, layout)
// No textarea auto-resize needed for <pre> blocks
})();
</script>
<style is:global>
.footer {
contain: layout style;
font-size: 0.8em;
line-height: 1.7em;
margin-top: 60px;
margin-bottom: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
color: rgba(0, 0, 0, 0.5);
}
.footer-inner {
max-width: 1280px;
margin: 0 auto;
padding: 60px 16px 48px;
display: grid;
grid-template-columns: 220px minmax(0, 680px) 260px;
gap: 32px;
align-items: start;
}
/* Use the parent grid (3 columns like .content-grid) */
.citation-block,
.references-block,
.reuse-block,
.doi-block {
display: contents;
}
.citation-block > h3,
.references-block > h3,
.reuse-block > h3,
.doi-block > h3 {
grid-column: 1;
font-size: 15px;
margin: 0;
text-align: right;
padding-right: 30px;
}
.citation-block > :not(h3),
.references-block > :not(h3),
.reuse-block > :not(h3),
.doi-block > :not(h3) {
grid-column: 2;
}
.citation-block h3 {
margin: 0 0 8px;
}
.citation-block h4 {
margin: 16px 0 8px;
font-size: 14px;
text-transform: uppercase;
color: var(--muted-color);
}
.citation-block p,
.reuse-block p,
.doi-block p,
.footnotes ol,
.footnotes ol p,
.references {
margin-top: 0;
}
/* Preserve KaTeX rendering in footnotes - essential for math formulas */
/* Compensate for footer's 0.8em font-size */
.footer .footnotes .katex {
font-size: 1.25em; /* 1em / 0.8em = 1.25em to compensate */
line-height: 1.21;
}
.footer .footnotes .katex-display {
margin: 1em 0;
text-align: center;
display: block;
overflow-x: auto;
overflow-y: hidden;
}
.footer .footnotes .katex-display > .katex {
display: block;
text-align: center;
}
/* Preserve KaTeX internal structure */
.footer .footnotes .katex .katex-html {
display: inline-block;
}
.footer .footnotes .katex .base {
display: inline-block;
}
/* Distill-like appendix citation styling */
.citation {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace;
font-size: 11px;
line-height: 15px;
border-left: 1px solid rgba(0, 0, 0, 0.1);
padding-left: 18px;
border: 1px solid rgba(0, 0, 0, 0.1);
background: rgba(0, 0, 0, 0.02);
padding: 10px 18px;
border-radius: 3px;
color: rgba(150, 150, 150, 1);
overflow: hidden;
margin-top: -12px;
white-space: pre-wrap;
word-wrap: break-word;
}
.citation a {
color: rgba(0, 0, 0, 0.6);
text-decoration: underline;
}
.citation.short {
margin-top: -4px;
}
.references-block h3 {
margin: 0;
}
/* Distill-like list styling for references/footnotes */
.references-block ol {
padding: 0 0 0 15px;
}
@media (min-width: 768px) {
.references-block ol {
padding: 0 0 0 30px;
margin-left: -30px;
}
}
.references-block li {
margin-bottom: 1em;
}
.references-block a {
color: var(--text-color);
}
[data-theme="dark"] .footer {
border-top-color: rgba(255, 255, 255, 0.15);
color: rgba(200, 200, 200, 0.8);
}
[data-theme="dark"] .citation {
background: rgba(255, 255, 255, 0.04);
border-color: rgba(255, 255, 255, 0.15);
color: rgba(200, 200, 200, 1);
}
[data-theme="dark"] .citation a {
color: rgba(255, 255, 255, 0.75);
}
/* Footer links: use primary color consistently */
.footer a {
color: var(--primary-color);
border-bottom: 1px solid var(--link-underline);
text-decoration: none;
}
.footer a:hover {
color: var(--primary-color-hover);
border-bottom-color: var(--link-underline-hover);
}
[data-theme="dark"] .footer a {
color: var(--primary-color);
}
/* Template credit - discrete at the bottom */
.template-credit {
display: contents;
}
.template-credit p {
grid-column: 2;
margin: 24px 0 0 0;
font-size: 0.85em;
color: rgba(0, 0, 0, 0.5);
}
.template-credit a {
color: rgba(0, 0, 0, 0.6);
border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.template-credit a:hover {
color: rgba(0, 0, 0, 0.8);
border-bottom-color: rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .template-credit p {
color: rgba(200, 200, 200, 0.6);
}
[data-theme="dark"] .template-credit a {
color: rgba(200, 200, 200, 0.7);
border-bottom-color: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .template-credit a:hover {
color: rgba(200, 200, 200, 0.9);
border-bottom-color: rgba(255, 255, 255, 0.35);
}
</style>
|