Skip to content

Commit 3aad858

Browse files
committed
fix lib/References.svelte mixing authors and titles on page reloads
sync references.yaml with Zotero collection
1 parent a549532 commit 3aad858

File tree

2 files changed

+680
-26
lines changed

2 files changed

+680
-26
lines changed

site/src/lib/References.svelte

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@
33
import type { Reference } from '.'
44
55
export let references: Reference[]
6-
export let ref_selector: string = `a[href^='#']`
6+
export let ref_selector: string = `a.ref[href^='#']`
77
export let found_on_page: Reference[] = references
88
99
function filter_refs() {
1010
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}`))
1313
}
1414
beforeUpdate(filter_refs)
1515
</script>
1616

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(`, &thinsp; `)}
23-
</span>
24-
&mdash;
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-
&mdash; {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(`, &thinsp; `)}
24+
</span>
25+
&mdash;
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+
&mdash; {issued[0].year}
34+
{/if}
35+
</small>
36+
</li>
37+
{/each}
38+
</ol>
39+
{/key}
3840

3941
<style>
4042
ol > li {

0 commit comments

Comments
 (0)