forked from MapComplete/MapComplete
Fix: check for type in TagLink
This commit is contained in:
parent
2cf0bc1866
commit
bd3c266a4d
1 changed files with 7 additions and 3 deletions
|
@ -1,12 +1,11 @@
|
|||
<script lang="ts">
|
||||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||
import tag2link from "tag2link/index.json"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
export let tags: UIEventSource<Record<string, any>>
|
||||
export let key: string
|
||||
|
||||
const values = $tags[key].split(";").map((v) => v.trim())
|
||||
|
||||
const tag2linkData = tag2link as Tag2LinkElement[]
|
||||
|
||||
interface Tag2LinkElement {
|
||||
|
@ -32,9 +31,14 @@
|
|||
}
|
||||
|
||||
const url = tag2linkData.find((item) => item.key === `Key:${key}`)?.url
|
||||
|
||||
const values: string[] =
|
||||
typeof $tags[key] === "string" ? $tags[key].split(";").map((v: string) => v.trim()) : []
|
||||
|
||||
console.log(`TagLink for ${key} values: [${values.join(", ")}]`)
|
||||
</script>
|
||||
|
||||
{#if url}
|
||||
{#if url && values.length > 0}
|
||||
{#each values as value, index}
|
||||
<span class="tag-link">
|
||||
{#if index > 0}; {/if}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue