File tree 5 files changed +28
-22
lines changed
ngx-notion-testbed-app/src
5 files changed +28
-22
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,8 @@ export class DatabaseItemComponent implements OnInit {
47
47
if ( response . data ) {
48
48
const blocks = response . data ;
49
49
blocks . forEach ( block => {
50
- if ( block . type === 'page' ) {
51
- this . imgSrc . set ( getBlockImageURL ( block . format ! . page_cover ! , block ! ) )
52
-
50
+ if ( block ?. type === 'page' && block . format ?. page_cover ) {
51
+ this . imgSrc . set ( getBlockImageURL ( block . format . page_cover ! , block ! ) )
53
52
}
54
53
} )
55
54
}
Original file line number Diff line number Diff line change 1
1
@let notionBlock = notionBlockSignal();
2
2
3
- < div class ="flex flex-col gap-3 w-full ">
4
- @defer {
5
- < div class ="h-[160px] w-full relative ">
6
- < img
7
- fill
8
- class ="object-cover rounded-3xl "
9
- title ="page_cover "
10
- priority
11
- [ngSrc] ="imgSrc() " />
12
- </ div >
13
- } @placeholder {
14
- < div class ="h-40 w-full bg-slate-100 rounded-3xl "> </ div >
15
- }
3
+ @if (notionBlock) {
4
+ < div class ="flex flex-col gap-3 w-full ">
5
+ @if (imgSrc()) {
6
+ @defer {
7
+ < div class ="h-[160px] w-full relative ">
8
+ < img
9
+ fill
10
+ class ="object-cover rounded-3xl "
11
+ title ="page_cover "
12
+ priority
13
+ [ngSrc] ="imgSrc() " />
14
+ </ div >
15
+ } @placeholder {
16
+ < div class ="h-40 w-full bg-slate-100 rounded-3xl "> </ div >
17
+ }
18
+ }
16
19
17
- < h1 class ="text-3xl font-bold mb-5 ">
18
- {{ (notionBlock.properties?.title)![0][0] }}
19
- </ h1 >
20
- </ div >
20
+ < h1 class ="text-3xl font-bold mb-5 ">
21
+ {{ (notionBlock.properties?.title)![0][0] }}
22
+ </ h1 >
23
+ </ div >
24
+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { NgOptimizedImage } from '@angular/common'
18
18
export class PageCoverComponent {
19
19
notionBlockSignal = input . required < NotionBlock > ( { 'alias' : 'notionBlock' } )
20
20
imgSrc = computed ( ( ) => {
21
- if ( this . notionBlockSignal ( ) . format ?. page_cover ) {
21
+ if ( this . notionBlockSignal ( ) . type && this . notionBlockSignal ( ) ?. format ?. page_cover ) {
22
22
return getBlockImageURL ( this . notionBlockSignal ( ) . format ! . page_cover ! , this . notionBlockSignal ( ) ! )
23
23
}
24
24
return ''
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ export class NgxNotionService {
24
24
if ( response . data ) {
25
25
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26
26
Object . values ( response . data ) . forEach ( ( key : any ) => {
27
- blocks . push ( key . value ) ;
27
+ if ( key . value ) {
28
+ blocks . push ( key . value ) ;
29
+ }
28
30
} ) ;
29
31
return {
30
32
data : blocks ,
Original file line number Diff line number Diff line change 6
6
< base href ="/ " />
7
7
< meta name ="viewport " content ="width=device-width, initial-scale=1 " />
8
8
< link rel ="icon " type ="image/x-icon " href ="image.ico " />
9
+ < link rel ="preconnect " href ="https://www.notion.so " />
9
10
</ head >
10
11
< body >
11
12
< app-root > </ app-root >
You can’t perform that action at this time.
0 commit comments