11import { diffToChanges } from "./diffToChanges.ts" ;
2- import type { Line } from "../../deps/scrapbox.ts" ;
3- import { Block , Node , parse } from "../../deps/scrapbox.ts" ;
2+ import { Block , Line , Node , parse } from "../../deps/scrapbox.ts" ;
3+ import { Page } from "../../deps/scrapbox-rest .ts" ;
44import type { Change } from "../../deps/socket.ts" ;
5- import type { HeadData } from "./pull.ts" ;
65import { toTitleLc } from "../../title.ts" ;
76import { parseYoutube } from "../../parser/youtube.ts" ;
87
98export interface Init {
109 userId : string ;
11- head : HeadData ;
10+ page : Page ;
1211}
1312export function * makeChanges (
1413 left : Pick < Line , "text" | "id" > [ ] ,
1514 right : string [ ] ,
16- { userId, head } : Init ,
15+ { userId, page } : Init ,
1716) : Generator < Change , void , unknown > {
1817 // 改行文字が入るのを防ぐ
1918 const right_ = right . flatMap ( ( text ) => text . split ( "\n" ) ) ;
@@ -24,7 +23,7 @@ export function* makeChanges(
2423
2524 // titleの差分を入れる
2625 // 空ページの場合もタイトル変更commitを入れる
27- if ( left [ 0 ] . text !== right_ [ 0 ] || ! head . persistent ) {
26+ if ( left [ 0 ] . text !== right_ [ 0 ] || ! page . persistent ) {
2827 yield { title : right_ [ 0 ] } ;
2928 }
3029
@@ -38,18 +37,18 @@ export function* makeChanges(
3837 // リンクと画像の差分を入れる
3938 const [ links , projectLinks , image ] = findLinksAndImage ( right_ . join ( "\n" ) ) ;
4039 if (
41- head . links . length !== links . length ||
42- ! head . links . every ( ( link ) => links . includes ( link ) )
40+ page . links . length !== links . length ||
41+ ! page . links . every ( ( link ) => links . includes ( link ) )
4342 ) {
4443 yield { links } ;
4544 }
4645 if (
47- head . projectLinks . length !== projectLinks . length ||
48- ! head . projectLinks . every ( ( link ) => projectLinks . includes ( link ) )
46+ page . projectLinks . length !== projectLinks . length ||
47+ ! page . projectLinks . every ( ( link ) => projectLinks . includes ( link ) )
4948 ) {
5049 yield { projectLinks } ;
5150 }
52- if ( head . image !== image ) {
51+ if ( page . image !== image ) {
5352 yield { image } ;
5453 }
5554}
0 commit comments