|
3 | 3 | import type { Reference } from '.'
|
4 | 4 |
|
5 | 5 | export let references: Reference[]
|
6 |
| - export let ref_selector: string = `a[href^='#']` |
| 6 | + export let ref_selector: string = `a.ref[href^='#']` |
7 | 7 | export let found_on_page: Reference[] = references
|
8 | 8 |
|
9 | 9 | function filter_refs() {
|
10 | 10 | const ref_links = document.querySelectorAll<HTMLAnchorElement>(ref_selector)
|
11 |
| - const hrefs = Array.from(ref_links).map((ref) => ref.hash) |
12 |
| - found_on_page = references.filter((ref) => hrefs.includes(`#${ref.id}`)) |
| 11 | + const hashes = Array.from(ref_links).map((ref) => ref.hash) |
| 12 | + found_on_page = references.filter((ref) => hashes.includes(`#${ref.id}`)) |
13 | 13 | }
|
14 | 14 | beforeUpdate(filter_refs)
|
15 | 15 | </script>
|
16 | 16 |
|
17 |
| -<ol> |
18 |
| - {#each found_on_page as { title, id, author, DOI, URL, issued }} |
19 |
| - <li> |
20 |
| - <strong {id}>{title}</strong> |
21 |
| - <span> |
22 |
| - {@html author.map((a) => `${a.given} ${a.family}`).join(`,   `)} |
23 |
| - </span> |
24 |
| - — |
25 |
| - <small> |
26 |
| - {#if DOI} |
27 |
| - DOI: <a href="https://doi.org/{DOI}">{DOI}</a> |
28 |
| - {:else if URL} |
29 |
| - preprint: <a href={URL}>{URL}</a> |
30 |
| - {/if} |
31 |
| - {#if issued} |
32 |
| - — {issued[0].year} |
33 |
| - {/if} |
34 |
| - </small> |
35 |
| - </li> |
36 |
| - {/each} |
37 |
| -</ol> |
| 17 | +{#key found_on_page} |
| 18 | + <ol> |
| 19 | + {#each found_on_page as { title, id, author, DOI, URL: href, issued } (id)} |
| 20 | + <li> |
| 21 | + <strong {id}>{title}</strong> |
| 22 | + <span> |
| 23 | + {@html author.map((a) => `${a.given} ${a.family}`).join(`,   `)} |
| 24 | + </span> |
| 25 | + — |
| 26 | + <small> |
| 27 | + {#if DOI} |
| 28 | + DOI: <a href="https://doi.org/{DOI}">{DOI}</a> |
| 29 | + {:else if href} |
| 30 | + preprint: <a {href}>{href}</a> |
| 31 | + {/if} |
| 32 | + {#if issued} |
| 33 | + — {issued[0].year} |
| 34 | + {/if} |
| 35 | + </small> |
| 36 | + </li> |
| 37 | + {/each} |
| 38 | + </ol> |
| 39 | +{/key} |
38 | 40 |
|
39 | 41 | <style>
|
40 | 42 | ol > li {
|
|
0 commit comments