File tree Expand file tree Collapse file tree 5 files changed +54
-20
lines changed Expand file tree Collapse file tree 5 files changed +54
-20
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,15 @@ The `NotionRenderer` component offers a few properties
15
15
16
16
- [ ` blockMap ` ] ( #blockMap ) – required
17
17
- [ ` contentId ` ] ( #contentId ) – default: ` undefined `
18
- - [ ` embedAllow ` ] ( #embedAllow ) – default: ` fullscreen `
18
+ - [ ` embedAllow ` ] ( #embedAllow ) – default: ` " fullscreen" `
19
19
- [ ` fullPage ` ] ( #fullPage ) – default: ` false `
20
20
- [ ` hideList ` ] ( #hideList ) – default: ` [] `
21
21
- [ ` mapImageUrl ` ] ( #mapImageUrl ) – default: ` defaultMapImageUrl() `
22
22
- [ ` mapPageUrl ` ] ( #mapPageUrl ) – default: ` defaultMapPageUrl() `
23
23
- [ ` pageLinkOptions ` ] ( #pageLinkOptions ) – default: ` undefined `
24
+ - [ ` pageLinkTarget ` ] ( #pageLinkTarget ) – default: ` "_self" `
25
+ - [ ` prism ` ] ( #prism ) – default: ` false `
26
+ - [ ` textLinkTarget ` ] ( #textLinkTarget ) – default: ` "_blank" `
24
27
25
28
### ` blockMap ` : Object
26
29
@@ -81,12 +84,20 @@ pageLinkOptions: {
81
84
}
82
85
```
83
86
87
+ ### ` pageLinkTarget ` : String
88
+
89
+ – the [ target attribute] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target ) of links referencing other pages (skipped for pages with ` pageLinkeOptions ` )
90
+
84
91
### ` prism ` : Boolean
85
92
86
93
– whether or not syntax-highlighting using Prims.js should be activated.
87
94
88
95
> Check the ` docs#syntax-highlighting ` section below for more details.
89
96
97
+ ### ` textLinkTarget ` : String
98
+
99
+ – the [ target attribute] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target ) of links
100
+
90
101
## Syntax-Highlighting
91
102
92
103
The following steps are required to add syntax-highlighting using Prism.js
Original file line number Diff line number Diff line change 1
1
<template >
2
+ <component
3
+ v-if =" isPageLink && hasPageLinkOptions"
4
+ class =" notion-page-link"
5
+ v-bind =" pageLinkProps(decoratorValue)"
6
+ :is =" pageLinkOptions.component"
7
+ >
8
+ {{ pageLinkTitle }}
9
+ </component >
2
10
<a
3
- v-if =" isPageLink"
11
+ v-else- if =" isPageLink"
4
12
class =" notion-link"
5
- target =" _blank "
6
- :href =" decoratorValue"
7
- >{{ pageLinkTitle }}
8
- </ a >
13
+ : target =" pageLinkTarget "
14
+ :href =" mapPageUrl( decoratorValue) "
15
+ >{{ pageLinkTitle }}</ a
16
+ >
9
17
<span v-else-if =" decorators.length === 0" >{{ text }}</span >
10
18
<span v-else-if =" decoratorKey === 'h'" :class =" 'notion-' + decoratorValue"
11
19
><NotionDecorator :content =" nextContent" v-bind =" pass" />
25
33
<a
26
34
v-else-if =" decoratorKey === 'a'"
27
35
class =" notion-link"
28
- target =" _blank "
36
+ : target =" target "
29
37
:href =" decoratorValue"
30
38
>
31
39
<NotionDecorator :content =" nextContent" v-bind =" pass" />
@@ -74,9 +82,15 @@ export default {
74
82
pageLinkTitle () {
75
83
return (
76
84
this .blockMap ? .[this .decoratorValue ]? .value ? .properties
77
- ? .title ? .[0 ]? .[0 ] || " this "
85
+ ? .title ? .[0 ]? .[0 ] || " link "
78
86
);
79
87
},
88
+ target () {
89
+ if (this .type === " page" ) {
90
+ return this .pageLinkTarget ;
91
+ }
92
+ return this .textLinkTarget ;
93
+ },
80
94
},
81
95
};
82
96
< / script>
Original file line number Diff line number Diff line change 29
29
<component
30
30
v-else-if =" hasPageLinkOptions"
31
31
class =" notion-page-link"
32
- v-bind =" pageLinkProps"
32
+ v-bind =" pageLinkProps(value.id) "
33
33
:is =" pageLinkOptions.component"
34
34
>
35
35
<div class =" notion-page-icon" >
39
39
<NotionTextRenderer :text =" title" v-bind =" pass" />
40
40
</div >
41
41
</component >
42
- <a v-else class =" notion-page-link" :href =" mapPageUrl(value.id)" >
42
+ <a
43
+ v-else
44
+ class =" notion-page-link"
45
+ :target =" pageLinkTarget"
46
+ :href =" mapPageUrl(value.id)"
47
+ >
43
48
<div class =" notion-page-icon" >
44
49
<NotionPageIcon v-bind =" pass" />
45
50
</div >
@@ -66,12 +71,6 @@ export default {
66
71
(1 - (this .format .page_cover_position || 0.5 )) * 100 ;
67
72
return { objectPosition: ` center ${ coverPosition} %` };
68
73
},
69
- hasPageLinkOptions () {
70
- return this .pageLinkOptions ? .component && this .pageLinkOptions ? .href ;
71
- },
72
- pageLinkProps () {
73
- return { [this .pageLinkOptions .href ]: this .mapPageUrl (this .value .id ) };
74
- },
75
74
},
76
75
};
77
76
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <p v-if =" properties" :class =" ['notion-text', blockColorClass]" >
2
+ <p v-if =" properties" :class =" ['notion-text', blockColorClass() ]" >
3
3
<NotionTextRenderer :text =" title" v-bind =" pass" />
4
4
</p >
5
5
<div v-else class =" notion-blank" >  ; </div >
6
6
</template >
7
7
8
8
<script >
9
- import Blockable , { blockComputed } from " @/lib/blockable" ;
9
+ import Blockable from " @/lib/blockable" ;
10
10
import NotionTextRenderer from " @/blocks/helpers/text-renderer" ;
11
11
12
12
export default {
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ export const blockProps = {
10
10
mapImageUrl : Function ,
11
11
mapPageUrl : Function ,
12
12
pageLinkOptions : Object ,
13
+ pageLinkTarget : { type : String , default : "_self" } ,
13
14
prism : { type : Boolean , default : false } ,
15
+ textLinkTarget : { type : String , default : "_blank" } ,
14
16
todo : { type : Boolean , default : false } ,
15
17
} ;
16
18
@@ -77,6 +79,9 @@ export const blockComputed = {
77
79
visible ( ) {
78
80
return ! this . hideList . includes ( this . type ) ;
79
81
} ,
82
+ hasPageLinkOptions ( ) {
83
+ return this . pageLinkOptions ?. component && this . pageLinkOptions ?. href ;
84
+ } ,
80
85
} ;
81
86
82
87
export default {
@@ -86,14 +91,19 @@ export default {
86
91
getTextContent,
87
92
isType ( t ) {
88
93
if ( Array . isArray ( t ) ) {
89
- return t . includes ( this . type ) && this . visible ;
94
+ return this . visible && t . includes ( this . type ) ;
90
95
}
91
96
92
- return this . type === t && this . visible ;
97
+ return this . visible && this . type === t ;
93
98
} ,
94
99
blockColorClass ( suffix = "" ) {
95
100
const blockColor = this . format ?. block_color ;
96
101
return blockColor ? `notion-${ blockColor } ${ suffix } ` : undefined ;
97
102
} ,
103
+ pageLinkProps ( id ) {
104
+ return {
105
+ [ this . pageLinkOptions . href ] : this . mapPageUrl ( id ) ,
106
+ } ;
107
+ } ,
98
108
} ,
99
109
} ;
You can’t perform that action at this time.
0 commit comments