Skip to content

Commit b425ae1

Browse files
authored
Merge pull request #57 from janniks/fix-page-links
Fix page links
2 parents 793ce60 + d15af79 commit b425ae1

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/blocks/decorator.vue

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<component
33
v-if="isPageLink && hasPageLinkOptions"
4-
class="notion-page-link"
4+
class="notion-link"
55
v-bind="pageLinkProps(decoratorValue)"
66
:is="pageLinkOptions.component"
77
>
@@ -14,6 +14,30 @@
1414
:href="mapPageUrl(decoratorValue)"
1515
>{{ pageLinkTitle }}</a
1616
>
17+
<component
18+
v-else-if="decoratorKey === 'a' && hasPageLinkOptions && isInlinePageLink"
19+
class="notion-link"
20+
v-bind="pageLinkProps(decoratorValue.slice(1))"
21+
:is="pageLinkOptions.component"
22+
>
23+
<NotionDecorator :content="nextContent" v-bind="pass" />
24+
</component>
25+
<a
26+
v-else-if="decoratorKey === 'a' && isInlinePageLink"
27+
class="notion-link"
28+
:target="target"
29+
:href="mapPageUrl(decoratorValue.slice(1))"
30+
>
31+
<NotionDecorator :content="nextContent" v-bind="pass" />
32+
</a>
33+
<a
34+
v-else-if="decoratorKey === 'a'"
35+
class="notion-link"
36+
:target="target"
37+
:href="decoratorValue"
38+
>
39+
<NotionDecorator :content="nextContent" v-bind="pass" />
40+
</a>
1741
<span v-else-if="decorators.length === 0">{{ text }}</span>
1842
<span v-else-if="decoratorKey === 'h'" :class="'notion-' + decoratorValue"
1943
><NotionDecorator :content="nextContent" v-bind="pass" />
@@ -30,14 +54,6 @@
3054
<s v-else-if="decoratorKey === 's'">
3155
<NotionDecorator :content="nextContent" v-bind="pass" />
3256
</s>
33-
<a
34-
v-else-if="decoratorKey === 'a'"
35-
class="notion-link"
36-
:target="target"
37-
:href="decoratorValue"
38-
>
39-
<NotionDecorator :content="nextContent" v-bind="pass" />
40-
</a>
4157
<component
4258
v-else-if="decoratorKey === 'e'"
4359
:is="'katex-element'"
@@ -79,6 +95,9 @@ export default {
7995
isPageLink() {
8096
return this.text === "";
8197
},
98+
isInlinePageLink() {
99+
return this.decoratorValue && this.decoratorValue[0] === "/";
100+
},
82101
pageLinkTitle() {
83102
return (
84103
this.blockMap?.[this.decoratorValue]?.value?.properties

0 commit comments

Comments
 (0)