# BaseLink
The BaseLink evaluates if the link is interal link.linktype === "story" or external link.linktype === "url".
Becomes either:
- Internal link:
<nuxt-link :to=""> - External:
<a href="" target="_blank" rel="noopener">
Storyblok
This component exists in Storyblok too.
blok: {
// required
link: {
id: '',
url: '',
fieldtype: 'multilink',
linktype: 'story' // story | url
cached_url: ''
},
// required
label: ''
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# Dependencies
This component uses a filter and a standard Nuxt component.
# Filter
- absolutPath.filter.js: For links with
linktype: storyStoryblok only returns the slug (e.g.blog), the filter makes sure that we always use the absolute path/blogand don't end up with something like thiscontact/blog.
# Components
- nuxt-link
# Required by
# Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| link | Object | true | - | Storyblok multilink field |
| label | String | true | - |
# Variants
- External (default):
.c-base-link--external, will be set iflink.linktype !== "story".
# Example
Good
<!-- Manually defined internal link -->
<BaseLink
:link="{
linktype: 'story',
cached_url: 'impressum'
}"
label="Impressum"
/>
<!-- Manually defined internal link -->
<BaseLink
:link="{
linktype: 'url',
cached_url: 'https://nueva.ch'
}"
label="nueva"
/>
<!-- Pass data from an object -->
<BaseLink :link="blok.link" :label="blok.label" />
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Bad
<!-- BaseLink does not have a slot, please use the props. -->
<BaseLink href="https://www.nueva.ch">nueva</BaseLink>
1
2
2
# TODO
- Icon for external link