Skip to content

Commit e94df45

Browse files
authored
Merge pull request #51 from dargmuesli/feat/links
feat(cookie): allow to add links
2 parents 15e55c5 + f91f889 commit e94df45

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

playground/nuxt.config.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default defineNuxtConfig({
1919
{
2020
description: {
2121
de: 'Dieser Cookie tut etwas.',
22-
en: 'This cookie does something.',
22+
en: 'This cookie does something very very very very very very very long.',
2323
},
2424
name: {
2525
de: 'Notwendiger Cookie',
@@ -30,12 +30,17 @@ export default defineNuxtConfig({
3030
],
3131
optional: [
3232
{
33-
name: 'Optional Cookie',
3433
id: 'op',
34+
name: 'Optional Cookie',
35+
links: {
36+
'https://example.com': 'Privacy Policy',
37+
'https://example.cop': null,
38+
},
3539
targetCookieIds: ['_o', '_p', '_t'],
3640
},
3741
],
3842
},
43+
isCookieIdVisible: true,
3944
locales: ['en', 'de'],
4045
},
4146
})

src/runtime/components/CookieControl.vue

+15-1
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,27 @@
119119
cookie.targetCookieIds
120120
"
121121
>
122+
<br />
122123
{{
123-
' IDs: ' +
124+
'IDs: ' +
124125
cookie.targetCookieIds
125126
.map((id: string) => `"${id}"`)
126127
.join(', ')
127128
}}
128129
</span>
130+
<template
131+
v-if="Object.entries(cookie.links || {}).length"
132+
>
133+
<span
134+
v-for="entry in Object.entries(
135+
cookie.links || {}
136+
)"
137+
:key="entry[0]"
138+
>
139+
<br />
140+
<a :href="entry[0]">{{ entry[1] || entry[0] }}</a>
141+
</span>
142+
</template>
129143
</label>
130144
</div>
131145
</li>

src/runtime/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface Cookie {
3131
description?: Translatable
3232
id?: string
3333
name: Translatable
34+
links?: Record<string, string | null>
3435
src?: string
3536
targetCookieIds?: string[]
3637
}

0 commit comments

Comments
 (0)