Skip to content

Commit 3091f1d

Browse files
committed
feat: support external links in footer *mandatoryLinks
1 parent 94f1e80 commit 3091f1d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/components/DsfrFooter/DsfrFooter.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ describe('DsfrFooter', () => {
9090
},
9191
props: {
9292
a11yCompliance: 'totalement conforme',
93-
afterMandatoryLinks: [{ label: 'After', to: testIdAfterLink }],
93+
afterMandatoryLinks: [
94+
{ label: 'After', to: testIdAfterLink },
95+
{ label: 'After ext', to: 'https://example.com' },
96+
],
9497
beforeMandatoryLinks: [{ label: 'Before', to: testIdBeforeLink }],
9598
partners,
9699
},
@@ -100,10 +103,13 @@ describe('DsfrFooter', () => {
100103

101104
const ecosystemLinksLis = container.querySelectorAll('.fr-footer__content-list .fr-footer__content-link')
102105
const partnerLinks = container.querySelectorAll('.fr-footer__partners-link')
106+
const bottomLinks = container.querySelectorAll('.fr-footer__bottom-link')
107+
const extLinks = [...bottomLinks].filter((link) => link.getAttribute('href')?.startsWith('https'))
103108

104109
// Then
105110
expect(ecosystemLinksLis).toHaveLength(4)
106111
expect(partnerLinks).toHaveLength(3)
112+
expect(extLinks).toHaveLength(1)
107113
expect(getByTestId(testIdMentionsLegales)).toHaveClass('fr-footer__bottom-link')
108114
expect(getByTestId(testIdBeforeLink)).toHaveClass('fr-footer__bottom-link')
109115
expect(getByTestId(testIdAfterLink)).toHaveClass('fr-footer__bottom-link')

src/components/DsfrFooter/DsfrFooter.types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export type DsfrFooterProps = {
3333
cookiesLink?: string
3434
logoText?: string | string[]
3535
descText?: string
36-
beforeMandatoryLinks?: {label: string, to: RouteLocationRaw | undefined}[]
37-
afterMandatoryLinks?: {label: string, to: RouteLocationRaw | undefined}[]
38-
mandatoryLinks?: {label: string, to: RouteLocationRaw | undefined}[]
36+
beforeMandatoryLinks?: {label: string, to: string | RouteLocationRaw | undefined}[]
37+
afterMandatoryLinks?: {label: string, to: string | RouteLocationRaw | undefined}[]
38+
mandatoryLinks?: {label: string, to: string | RouteLocationRaw | undefined}[]
3939
ecosystemLinks?: {label: string, href: string}[]
4040
operatorLinkText?: string
4141
operatorTo?: RouteLocationRaw | undefined

src/components/DsfrFooter/DsfrFooter.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,14 @@ const aLicenceHref = computed(() => {
187187
:key="index"
188188
class="fr-footer__bottom-item"
189189
>
190+
<a
191+
v-if="typeof link.to === 'string' && link.to.startsWith('http')"
192+
class="fr-footer__bottom-link"
193+
:href="link.to"
194+
:data-testid="link.to"
195+
>{{ link.label }}</a>
190196
<RouterLink
197+
v-else
191198
class="fr-footer__bottom-link"
192199
:to="link.to ?? '#'"
193200
:data-testid="link.to"

0 commit comments

Comments
 (0)