File tree Expand file tree Collapse file tree 6 files changed +62
-10
lines changed
packages/content/src/plugins Expand file tree Collapse file tree 6 files changed +62
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @bluecadet/launchpad-content " : patch
3
+ ---
4
+
5
+ Ensure all content plugins log on start and success.
Original file line number Diff line number Diff line change @@ -26,8 +26,11 @@ export default function mdToHtml(options: z.input<typeof mdToHtmlSchema>) {
26
26
return defineContentPlugin ( {
27
27
name : "md-to-html" ,
28
28
hooks : {
29
- onContentFetchDone ( ctx ) {
30
- return applyTransformToFiles ( {
29
+ async onContentFetchDone ( ctx ) {
30
+ let transformCount = 0 ;
31
+ ctx . logger . info ( "Transforming Markdown strings to HTML..." ) ;
32
+
33
+ await applyTransformToFiles ( {
31
34
dataStore : ctx . data ,
32
35
path,
33
36
keys,
@@ -44,10 +47,16 @@ export default function mdToHtml(options: z.input<typeof mdToHtmlSchema>) {
44
47
md . use ( markdownItItalicBold ) ;
45
48
return md . renderInline ( sanitizedStr ) ;
46
49
}
50
+
51
+ transformCount ++ ;
47
52
48
53
return md . render ( sanitizedStr ) ;
49
54
} ,
50
55
} ) ;
56
+
57
+ ctx . logger . info (
58
+ `Transformed ${ transformCount } Markdown strings.` ,
59
+ ) ;
51
60
} ,
52
61
} ,
53
62
} ) ;
Original file line number Diff line number Diff line change @@ -50,8 +50,14 @@ export default function sanityImageUrlTransform(
50
50
return defineContentPlugin ( {
51
51
name : "sanity-to-html" ,
52
52
hooks : {
53
- onContentFetchDone ( ctx ) {
54
- return applyTransformToFiles ( {
53
+ async onContentFetchDone ( ctx ) {
54
+ let transformCount = 0 ;
55
+
56
+ ctx . logger . info (
57
+ "Transforming URLs using Sanity Image URL Transform..." ,
58
+ ) ;
59
+
60
+ await applyTransformToFiles ( {
55
61
dataStore : ctx . data ,
56
62
path,
57
63
keys,
@@ -62,13 +68,18 @@ export default function sanityImageUrlTransform(
62
68
}
63
69
64
70
const transformedUrl = buildUrl ( builder . image ( content ) ) . url ( ) ;
71
+ transformCount ++ ;
65
72
66
73
return {
67
74
...content ,
68
75
[ newProperty ] : transformedUrl ,
69
76
} ;
70
77
} ,
71
78
} ) ;
79
+
80
+ ctx . logger . info (
81
+ `Transformed ${ transformCount } URLs.` ,
82
+ ) ;
72
83
} ,
73
84
} ,
74
85
} ) ;
Original file line number Diff line number Diff line change @@ -19,8 +19,11 @@ export default function sanityToHtml(options: z.input<typeof sanityToHtmlSchema>
19
19
return defineContentPlugin ( {
20
20
name : "sanity-to-html" ,
21
21
hooks : {
22
- onContentFetchDone ( ctx ) {
23
- return applyTransformToFiles ( {
22
+ async onContentFetchDone ( ctx ) {
23
+ let transformCount = 0 ;
24
+ ctx . logger . info ( "Transforming sanity blocks to HTML..." ) ;
25
+
26
+ await applyTransformToFiles ( {
24
27
dataStore : ctx . data ,
25
28
path,
26
29
keys,
@@ -30,9 +33,15 @@ export default function sanityToHtml(options: z.input<typeof sanityToHtmlSchema>
30
33
throw new Error ( `Content is not a valid Sanity text block: ${ content } ` ) ;
31
34
}
32
35
36
+ transformCount ++ ;
37
+
33
38
return toHTML ( content ) ;
34
39
} ,
35
40
} ) ;
41
+
42
+ ctx . logger . info (
43
+ `Transformed ${ transformCount } Sanity blocks to HTML.` ,
44
+ ) ;
36
45
} ,
37
46
} ,
38
47
} ) ;
Original file line number Diff line number Diff line change @@ -19,8 +19,11 @@ export default function sanityToMd(options: z.input<typeof sanityToMdSchema>) {
19
19
return defineContentPlugin ( {
20
20
name : "sanity-to-markdown" ,
21
21
hooks : {
22
- onContentFetchDone ( ctx ) {
23
- return applyTransformToFiles ( {
22
+ async onContentFetchDone ( ctx ) {
23
+ let transformCount = 0 ;
24
+ ctx . logger . info ( "Transforming sanity blocks to markdown..." ) ;
25
+
26
+ await applyTransformToFiles ( {
24
27
dataStore : ctx . data ,
25
28
path,
26
29
keys,
@@ -30,9 +33,15 @@ export default function sanityToMd(options: z.input<typeof sanityToMdSchema>) {
30
33
throw new Error ( `Content is not a valid Sanity text block: ${ content } ` ) ;
31
34
}
32
35
36
+ transformCount ++ ;
37
+
33
38
return toMarkdown ( content ) ;
34
39
} ,
35
40
} ) ;
41
+
42
+ ctx . logger . info (
43
+ `Transformed ${ transformCount } Sanity blocks to markdown.` ,
44
+ ) ;
36
45
} ,
37
46
} ,
38
47
} ) ;
Original file line number Diff line number Diff line change @@ -17,8 +17,11 @@ export default function sanityToPlain(options: z.input<typeof sanityToPlainSchem
17
17
return defineContentPlugin ( {
18
18
name : "sanity-to-plain" ,
19
19
hooks : {
20
- onContentFetchDone ( ctx ) {
21
- return applyTransformToFiles ( {
20
+ async onContentFetchDone ( ctx ) {
21
+ let transformCount = 0 ;
22
+ ctx . logger . info ( "Transforming sanity blocks to plain text..." ) ;
23
+
24
+ await applyTransformToFiles ( {
22
25
dataStore : ctx . data ,
23
26
path,
24
27
keys,
@@ -28,9 +31,15 @@ export default function sanityToPlain(options: z.input<typeof sanityToPlainSchem
28
31
throw new Error ( `Content is not a valid Sanity text block: ${ content } ` ) ;
29
32
}
30
33
34
+ transformCount ++ ;
35
+
31
36
return content . children . map ( ( child ) => child . text ) . join ( "" ) ;
32
37
} ,
33
38
} ) ;
39
+
40
+ ctx . logger . info (
41
+ `Transformed ${ transformCount } Sanity blocks to plain text.` ,
42
+ ) ;
34
43
} ,
35
44
} ,
36
45
} ) ;
You can’t perform that action at this time.
0 commit comments