@@ -59,28 +59,28 @@ async function createGoogleSyndicationTask({ title, canonicalUrl, tags = [] }) {
5959 }
6060
6161 const hnUrl = `https://news.ycombinator.com/submitlink?u=${ encodeURIComponent ( canonicalUrl ) } &t=${ encodeURIComponent ( title ) } ` ;
62- const taskTitle = `Post: ${ title } ` ;
62+ const taskTitle = title ;
63+ // Put canonicalUrl on Line 1 so it is immediately clickable on the Google Tasks card preview
6364 const taskNotes = [
64- `📌 COPY-PASTE TITLE:` ,
65- title ,
66- `` ,
67- `🔗 CANONICAL URL:` ,
6865 canonicalUrl ,
6966 `Tags: ${ tags . join ( ", " ) } ` ,
70- `` ,
71- `🚀 1-TAP CROSS-POST LINKS:` ,
72- `1. Hacker News (1-Tap Submit):` ,
73- ` ${ hnUrl } ` ,
74- `` ,
75- `2. Medium (1-Click Import - automatically sets canonical tag):` ,
76- ` https://medium.com/p/import` ,
77- ` Paste: ${ canonicalUrl } ` ,
78- `` ,
79- `3. Hashnode (Free UI Editor):` ,
80- ` https://hashnode.com/draft` ,
81- ` Original Article URL: ${ canonicalUrl } ` ,
8267 ] . join ( "\n" ) ;
8368
69+ const subtasks = [
70+ {
71+ title : "3. Cross-post to Hashnode" ,
72+ notes : `https://hashnode.com/draft\nCanonical URL: ${ canonicalUrl } ` ,
73+ } ,
74+ {
75+ title : "2. Import to Medium (1-Click)" ,
76+ notes : `https://medium.com/p/import\nPaste URL: ${ canonicalUrl } ` ,
77+ } ,
78+ {
79+ title : "1. Submit to Hacker News (1-Tap Pre-filled)" ,
80+ notes : `${ hnUrl } \nTitle: ${ title } ` ,
81+ } ,
82+ ] ;
83+
8484 // 1. Try Google Tasks API first (targeting the "CodingCat.dev Posts" list)
8585 let targetListId = "@default" ;
8686 const listsRes = await fetch ( "https://tasks.googleapis.com/tasks/v1/users/@me/lists?maxResults=100" , {
@@ -118,8 +118,9 @@ async function createGoogleSyndicationTask({ title, canonicalUrl, tags = [] }) {
118118 const existingData = await existingTasksRes . json ( ) ;
119119 const existingTask = ( existingData . items || [ ] ) . find (
120120 ( t ) =>
121- ( t . notes && t . notes . includes ( canonicalUrl ) ) ||
122- ( t . title && t . title . toLowerCase ( ) === taskTitle . toLowerCase ( ) )
121+ ! t . parent &&
122+ ( ( t . notes && t . notes . includes ( canonicalUrl ) ) ||
123+ ( t . title && t . title . toLowerCase ( ) === taskTitle . toLowerCase ( ) ) )
123124 ) ;
124125 if ( existingTask ) {
125126 console . log ( `✓ Google Task already exists in "CodingCat.dev Posts": "${ taskTitle } " (ID: ${ existingTask . id } )` ) ;
@@ -146,6 +147,19 @@ async function createGoogleSyndicationTask({ title, canonicalUrl, tags = [] }) {
146147 if ( tasksRes . ok ) {
147148 const createdTask = await tasksRes . json ( ) ;
148149 console . log ( `✓ Created Google Task in "CodingCat.dev Posts": "${ taskTitle } " (ID: ${ createdTask . id } )` ) ;
150+ for ( const st of subtasks ) {
151+ await fetch (
152+ `https://tasks.googleapis.com/tasks/v1/lists/${ encodeURIComponent ( targetListId ) } /tasks?parent=${ encodeURIComponent ( createdTask . id ) } ` ,
153+ {
154+ method : "POST" ,
155+ headers : {
156+ Authorization : `Bearer ${ accessToken } ` ,
157+ "Content-Type" : "application/json" ,
158+ } ,
159+ body : JSON . stringify ( st ) ,
160+ }
161+ ) ;
162+ }
149163 return ;
150164 }
151165 }
0 commit comments