|
| 1 | +{%- comment -%} |
| 2 | + Citation block for project pages that have an accompanying paper. |
| 3 | + |
| 4 | + Renders nothing unless the page defines `bibtex` in its front matter, so it is |
| 5 | + safe to drop into any project layout. Expected front matter (see |
| 6 | + _projects/every_eval_ever.md for a worked example): |
| 7 | + |
| 8 | + paper_url, paper_arxiv, paper_title, paper_authors, paper_year, bibtex |
| 9 | + |
| 10 | + `paper_authors` is rendered verbatim, so it should include its own terminal |
| 11 | + punctuation (e.g. "Jan Batzner, Sree Harsha Nelaturu, Damian Stachura, et al."). |
| 12 | + |
| 13 | + Styled with the design tokens (--bg, --bg-subtle, --fg, --fg-muted, --fg-subtle, |
| 14 | + --border, --accent) that the eval_cards and every_eval_ever layouts define, so it |
| 15 | + picks up light and dark mode on those pages without per-layout tailoring. Those |
| 16 | + tokens are not defined site-wide, so every reference carries the light-mode value |
| 17 | + as a fallback — that keeps the block styled correctly on the generic project |
| 18 | + layout too. |
| 19 | +{%- endcomment -%} |
| 20 | +{% if page.bibtex %} |
| 21 | +<!-- ===================== CITATION ===================== --> |
| 22 | +<section id="cite" class="py-16 sm:py-20 px-4 sm:px-6 lg:px-8" |
| 23 | + style="background: var(--bg-subtle, #f5f4f1); border-top: 1px solid var(--border, #e8e6e1);"> |
| 24 | + <div class="max-w-3xl mx-auto"> |
| 25 | + |
| 26 | + <div class="cite-kicker">Citation</div> |
| 27 | + <h2 class="font-bold mt-3 mb-4" |
| 28 | + style="font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.01em; color: var(--fg, #1a1916);"> |
| 29 | + Cite this work |
| 30 | + </h2> |
| 31 | + |
| 32 | + <p class="text-sm sm:text-base leading-relaxed mb-5" style="color: var(--fg-muted, #5c5a55);"> |
| 33 | + If {{ page.title }} informs your research, please cite the paper: |
| 34 | + </p> |
| 35 | + |
| 36 | + {%- comment -%} |
| 37 | + `paper_authors` carries its own terminal punctuation (author lists usually end |
| 38 | + in "et al."), so don't append a period here or it doubles up. |
| 39 | + {%- endcomment -%} |
| 40 | + <p class="text-sm sm:text-base leading-relaxed mb-6" style="color: var(--fg-muted, #5c5a55);"> |
| 41 | + {% if page.paper_authors %}{{ page.paper_authors }}{% endif %} |
| 42 | + {% if page.paper_year %}{{ page.paper_year }}.{% endif %} |
| 43 | + <em style="color: var(--fg, #1a1916);">{{ page.paper_title | default: page.title }}</em>. |
| 44 | + {% if page.paper_arxiv %}arXiv:{{ page.paper_arxiv }}.{% endif %} |
| 45 | + {% if page.paper_url %} |
| 46 | + <a href="{{ page.paper_url }}" target="_blank" rel="noopener" |
| 47 | + class="cite-link">Read it here<span aria-hidden="true"> →</span></a> |
| 48 | + {% endif %} |
| 49 | + </p> |
| 50 | + |
| 51 | + <div class="cite-block"> |
| 52 | + <button type="button" class="cite-copy" data-cite-copy aria-label="Copy BibTeX to clipboard"> |
| 53 | + <i data-lucide="clipboard" class="w-3.5 h-3.5"></i> |
| 54 | + <span data-cite-copy-label>Copy</span> |
| 55 | + </button> |
| 56 | + <pre data-cite-bibtex>{{ page.bibtex | strip | escape }}</pre> |
| 57 | + </div> |
| 58 | + |
| 59 | + </div> |
| 60 | +</section> |
| 61 | + |
| 62 | +<style> |
| 63 | + #cite .cite-kicker { |
| 64 | + font-family: var(--font-mono, 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace); |
| 65 | + font-size: 11px; |
| 66 | + letter-spacing: .14em; |
| 67 | + text-transform: uppercase; |
| 68 | + color: var(--fg-subtle, #9c9a95); |
| 69 | + } |
| 70 | + #cite .cite-link { |
| 71 | + color: var(--accent, #5bacd1); |
| 72 | + font-weight: 500; |
| 73 | + text-decoration: underline; |
| 74 | + text-underline-offset: 2px; |
| 75 | + white-space: nowrap; |
| 76 | + } |
| 77 | + #cite .cite-block { position: relative; } |
| 78 | + #cite pre { |
| 79 | + margin: 0; |
| 80 | + padding: 1.25rem 1.25rem 1.25rem; |
| 81 | + background: var(--bg, #ffffff); |
| 82 | + border: 1px solid var(--border, #e8e6e1); |
| 83 | + border-radius: 8px; |
| 84 | + overflow-x: auto; |
| 85 | + font-family: var(--font-mono, 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace); |
| 86 | + font-size: 12px; |
| 87 | + line-height: 1.7; |
| 88 | + color: var(--fg-muted, #5c5a55); |
| 89 | + /* BibTeX is pre-wrapped by arXiv; keep long author lists scrollable, not reflowed. */ |
| 90 | + white-space: pre; |
| 91 | + tab-size: 2; |
| 92 | + } |
| 93 | + #cite .cite-copy { |
| 94 | + position: absolute; |
| 95 | + top: .625rem; |
| 96 | + right: .625rem; |
| 97 | + display: inline-flex; |
| 98 | + align-items: center; |
| 99 | + gap: .375rem; |
| 100 | + padding: .3rem .6rem; |
| 101 | + background: var(--bg-subtle, #f5f4f1); |
| 102 | + border: 1px solid var(--border, #e8e6e1); |
| 103 | + border-radius: 5px; |
| 104 | + font-family: var(--font-mono, 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace); |
| 105 | + font-size: 11px; |
| 106 | + color: var(--fg-muted, #5c5a55); |
| 107 | + cursor: pointer; |
| 108 | + transition: color .2s, border-color .2s; |
| 109 | + } |
| 110 | + #cite .cite-copy:hover { color: var(--fg, #1a1916); border-color: var(--border-strong, #c8c6c0); } |
| 111 | + #cite .cite-copy[data-copied] { color: var(--accent, #5bacd1); border-color: var(--accent, #5bacd1); } |
| 112 | + @media (max-width: 640px) { |
| 113 | + /* Don't let the button sit on top of the first line of the entry. */ |
| 114 | + #cite pre { padding-top: 2.75rem; } |
| 115 | + } |
| 116 | +</style> |
| 117 | + |
| 118 | +<script> |
| 119 | + (function () { |
| 120 | + var btn = document.querySelector('#cite [data-cite-copy]'); |
| 121 | + var pre = document.querySelector('#cite [data-cite-bibtex]'); |
| 122 | + if (!btn || !pre) return; |
| 123 | + |
| 124 | + var label = btn.querySelector('[data-cite-copy-label]'); |
| 125 | + var reset; |
| 126 | + |
| 127 | + function flash(text) { |
| 128 | + if (label) label.textContent = text; |
| 129 | + btn.setAttribute('data-copied', ''); |
| 130 | + clearTimeout(reset); |
| 131 | + reset = setTimeout(function () { |
| 132 | + if (label) label.textContent = 'Copy'; |
| 133 | + btn.removeAttribute('data-copied'); |
| 134 | + }, 2000); |
| 135 | + } |
| 136 | + |
| 137 | + btn.addEventListener('click', function () { |
| 138 | + // textContent decodes the Liquid-escaped entities, so the clipboard gets |
| 139 | + // BibTeX that compiles as-is. |
| 140 | + var bibtex = pre.textContent; |
| 141 | + |
| 142 | + if (navigator.clipboard && window.isSecureContext) { |
| 143 | + navigator.clipboard.writeText(bibtex).then(function () { |
| 144 | + flash('Copied'); |
| 145 | + }).catch(function () { |
| 146 | + flash('Press ⌘C'); |
| 147 | + }); |
| 148 | + return; |
| 149 | + } |
| 150 | + |
| 151 | + // Fallback for non-secure contexts (e.g. plain-http local previews). |
| 152 | + try { |
| 153 | + var ta = document.createElement('textarea'); |
| 154 | + ta.value = bibtex; |
| 155 | + ta.setAttribute('readonly', ''); |
| 156 | + ta.style.position = 'fixed'; |
| 157 | + ta.style.opacity = '0'; |
| 158 | + document.body.appendChild(ta); |
| 159 | + ta.select(); |
| 160 | + var ok = document.execCommand('copy'); |
| 161 | + document.body.removeChild(ta); |
| 162 | + flash(ok ? 'Copied' : 'Press ⌘C'); |
| 163 | + } catch (e) { |
| 164 | + flash('Press ⌘C'); |
| 165 | + } |
| 166 | + }); |
| 167 | + })(); |
| 168 | +</script> |
| 169 | +{% endif %} |
0 commit comments