@@ -42,20 +42,28 @@ export function* makeChanges(
42
42
}
43
43
44
44
// リンクと画像の差分を入れる
45
- const [ links , image ] = findLinksAndImage ( right_ . join ( "\n" ) ) ;
45
+ const [ links , projectLinks , image ] = findLinksAndImage ( right_ . join ( "\n" ) ) ;
46
46
if (
47
47
head . links . length !== links . length ||
48
48
! head . links . every ( ( link ) => links . includes ( link ) )
49
49
) {
50
50
yield { links } ;
51
51
}
52
+ if (
53
+ head . projectLinks . length !== projectLinks . length ||
54
+ ! head . projectLinks . every ( ( link ) => projectLinks . includes ( link ) )
55
+ ) {
56
+ yield { projectLinks } ;
57
+ }
52
58
if ( head . image !== image ) {
53
59
yield { image } ;
54
60
}
55
61
}
56
62
57
63
/** テキストに含まれる全てのリンクと最初の画像を探す */
58
- const findLinksAndImage = ( text : string ) : [ string [ ] , string | null ] => {
64
+ const findLinksAndImage = (
65
+ text : string ,
66
+ ) : [ string [ ] , string [ ] , string | null ] => {
59
67
const rows = parseToRows ( text ) ;
60
68
const blocks = packRows ( rows , { hasTitle : true } ) . flatMap ( ( pack ) => {
61
69
switch ( pack . type ) {
@@ -77,6 +85,8 @@ const findLinksAndImage = (text: string): [string[], string | null] => {
77
85
*/
78
86
const linksLc = new Map < string , boolean > ( ) ;
79
87
const links = [ ] as string [ ] ;
88
+ const projectLinksLc = new Set < string > ( ) ;
89
+ const projectLinks = [ ] as string [ ] ;
80
90
let image : string | null = null ;
81
91
82
92
const lookup = ( node : Node ) => {
@@ -93,6 +103,11 @@ const findLinksAndImage = (text: string): [string[], string | null] => {
93
103
linksLc . set ( toTitleLc ( node . href ) , true ) ;
94
104
links . push ( node . href ) ;
95
105
return ;
106
+ case "root" :
107
+ if ( projectLinksLc . has ( toTitleLc ( node . href ) ) ) return ;
108
+ projectLinksLc . add ( toTitleLc ( node . href ) ) ;
109
+ projectLinks . push ( node . href ) ;
110
+ return ;
96
111
case "absolute" : {
97
112
const props = parseYoutube ( node . href ) ;
98
113
if ( ! props || props . pathType === "list" ) return ;
@@ -125,7 +140,7 @@ const findLinksAndImage = (text: string): [string[], string | null] => {
125
140
lookup ( node ) ;
126
141
}
127
142
128
- return [ links , image ] ;
143
+ return [ links , projectLinks , image ] ;
129
144
} ;
130
145
131
146
function * blocksToNodes ( blocks : Iterable < Block > ) {
0 commit comments