File size: 6,755 Bytes
b565d01
 
 
 
 
 
a1ed00a
b565d01
a1ed00a
b565d01
 
 
 
 
 
 
 
 
 
 
a1ed00a
 
 
 
 
 
b565d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1ed00a
b565d01
 
 
 
 
 
 
a1ed00a
b565d01
 
 
 
 
 
 
 
 
 
 
a1ed00a
b565d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1ed00a
b565d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
interface Props {
  citationText: string;
  bibtex: string;
  licence?: string;
  doi?: string;
  acknowledgements?: string;
}
const { citationText, bibtex, licence, doi, acknowledgements } = Astro.props as Props;
---
<footer class="footer">
  <div class="footer-inner">
    <section class="citation-block">
      <h3>Citation</h3>
      <p>For attribution, cite this work as</p>
      <pre class="citation short">{citationText}</pre>

      <p>BibTeX citation</p>
      <pre class="citation long">{bibtex}</pre>
    </section>
    {acknowledgements && (
      <section class="acknowledgements-block">
        <h3>Acknowledgements</h3>
        <p set:html={acknowledgements}></p>
      </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}></p>
      </section>
    )}
    <section class="references-block">
      <slot />
    </section>
  </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();
        }
      }
      ensureHeading(headingText);
      target.appendChild(element);
      return true;
    };
    const run = () => {
      const findFirstOutsideFooter = (selectors) => {
        for (const sel of selectors) {
          const el = contentRoot.querySelector(sel);
          if (el && !footer.contains(el)) return el;
        }
        return null;
      };

      const referencesEl = findFirstOutsideFooter(['#references', '.references', '.bibliography']);
      const footnotesEl = findFirstOutsideFooter(['.footnotes']);

      const movedRefs = moveIntoFooter(referencesEl, 'References');
      const movedNotes = moveIntoFooter(footnotesEl, 'Footnotes');
      return movedRefs || movedNotes;
    };

    // Try now; if not found yet, try again on DOM ready
    const done = run();
    if (!done) {
      const onReady = () => run();
      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', onReady, { once: true });
      } else {
        setTimeout(onReady, 0);
      }
    }

    // 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,
  .acknowledgements-block,
  .references-block,
  .reuse-block,
  .doi-block {
    display: contents;
  }

  .citation-block > h3,
  .acknowledgements-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),
  .acknowledgements-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,
  .acknowledgements-block p,
  .reuse-block p,
  .doi-block p,
  .footnotes ol,
  .footnotes ol p,
  .references {
    margin-top: 0;
  }

  /* 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,.15); color: rgba(200,200,200,.8); }
  [data-theme="dark"] .citation { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,.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);
  }
</style>