Commit b13892dd57

b13892dd57aaea53af9c1d9da060a71fe87350cd

parent: cf316262e4

Unsigned

taskylizard <75871323+taskylizard@users.noreply.github.com> · 2026-04-27 16:55 UTC

feat: metadata for scrape table

Layout: unified · split

docs/.vitepress/theme/components/ScrapeTable.vue +40 −6
@@ -2,15 +2,46 @@
22import { useEventListener } from '@vueuse/core'
33import { computed, ref, onMounted } from 'vue'
44
5interface ScrapeValueObject {
6 name: string
7 metadata?: string[]
8}
9
10type ScrapeValue = string | ScrapeValueObject
11
12interface NormalizedScrapeValue {
13 name: string
14 metadata: string[]
15}
16
517interface Site {
618 name: string
7 scrapes: Record<string, string>
19 scrapes: Record<string, ScrapeValue>
820}
921
1022const props = defineProps<{
1123 sites: Site[]
1224}>()
1325
26function normalizeScrapeValue(value: ScrapeValue): NormalizedScrapeValue {
27 if (typeof value === 'string') {
28 return { name: value, metadata: [] }
29 }
30
31 return {
32 name: value.name,
33 metadata: value.metadata ?? [],
34 }
35}
36
37function hasMetadata(value: NormalizedScrapeValue | undefined, metadata: string) {
38 return value?.metadata.some(item => item.toLowerCase() === metadata.toLowerCase()) ?? false
39}
40
41function getScrapeTitle(value: NormalizedScrapeValue | undefined) {
42 return value?.name || undefined
43}
44
1445// Normalize source names (case-insensitive dedup, keep first-seen casing)
1546const normalizedSites = computed(() => {
1647 const canonical: Record<string, string> = {}
@@ -21,9 +52,9 @@ const normalizedSites = computed(() => {
2152 }
2253 }
2354 return props.sites.map(site => {
24 const scrapes: Record<string, string> = {}
25 for (const [source, player] of Object.entries(site.scrapes)) {
26 scrapes[canonical[source.toLowerCase()]] = player
55 const scrapes: Record<string, NormalizedScrapeValue> = {}
56 for (const [source, value] of Object.entries(site.scrapes)) {
57 scrapes[canonical[source.toLowerCase()]] = normalizeScrapeValue(value)
2758 }
2859 return { name: site.name, scrapes }
2960 })
@@ -125,8 +156,11 @@ onMounted(() => {
125156 v-for="source in sources"
126157 :key="source"
127158 class="cell"
128 :class="{ active: source in site.scrapes }"
129 :title="site.scrapes[source] || undefined"
159 :class="{
160 active: source in site.scrapes,
161 'active-sd': hasMetadata(site.scrapes[source], 'SD'),
162 }"
163 :title="getScrapeTitle(site.scrapes[source])"
130164 />
131165 </tr>
132166 </tbody>
docs/.vitepress/theme/styles/style.scss +5
@@ -1444,6 +1444,7 @@ table tr:nth-child(odd) {
14441444:root {
14451445 --scrape-cell-bg: #ebedf0;
14461446 --scrape-cell-active: #56d364;
1447 --scrape-cell-active-sd: #ff4d4f;
14471448}
14481449
14491450.dark {
@@ -1544,6 +1545,10 @@ table tr:nth-child(odd) {
15441545 background: var(--scrape-cell-active);
15451546 }
15461547
1548 &.active-sd::before {
1549 background: var(--scrape-cell-active-sd);
1550 }
1551
15471552 &.active[title]:hover::after {
15481553 content: attr(title);
15491554 position: absolute;