PageSourceSearch

https://federicobruzzone.github.io/scripts/load-bib.js

js federicobruzzone.github.io collected 2026-10-03 09:11:22 UTC 1,374 bytes, 40 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function() {
2    const bibtex = document.querySelector('.bibtex');
3    if (!bibtex) {
4        return;
5    }
6    const folder = document.getElementById('root-folder').getAttribute('value');
7
8    const pageTitle = document.querySelector('h1') ? document.querySelector('h1').textContent.trim() : 'Untitled';
9    const pageUrl = window.location.href;
10    const pageYear = bibtex.getAttribute('year');
11    const pageMonth = bibtex.getAttribute('month');
12    const pageDate = new Date().toISOString().split('T')[0];
13
14    const bibContent = `
15@misc{${pageTitle.replace(/\s+/g, '_').toLowerCase()}_${pageYear},
16  author = {Bruzzone, Federico},
17  title = {${pageTitle}},
18  url   = {${pageUrl}},
19  note  = {Blog post, accessed: ${pageDate}},
20  year  = {${pageYear}},
21  month = {${pageMonth}},
22}
23    `;
24
25    const pre = document.createElement('pre');
26    const code = document.createElement('code');
27    code.className = "language-bibtex";
28    code.textContent = bibContent.trim();
29    pre.appendChild(code);
30
31    const p = document.createElement('p');
32    p.innerHTML = `If you found this page useful, please consider citing it using the following BibTeX entry:`;
33
34    const h2 = document.createElement('h2');
35    h2.textContent = "Cite this page";
36
37    bibtex.appendChild(h2);
38    bibtex.appendChild(p);
39    bibtex.appendChild(pre);
40});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.