diff --git a/scripts/run-syndicate-post.mjs b/scripts/run-syndicate-post.mjs index c456af98..00ee388b 100644 --- a/scripts/run-syndicate-post.mjs +++ b/scripts/run-syndicate-post.mjs @@ -60,16 +60,25 @@ async function createGoogleSyndicationTask({ title, canonicalUrl, tags = [] }) { const hnUrl = `https://news.ycombinator.com/submitlink?u=${encodeURIComponent(canonicalUrl)}&t=${encodeURIComponent(title)}`; const taskTitle = title; - // Put canonicalUrl on Line 1 so it is immediately clickable on the Google Tasks card preview + const baseDocId = String(docId).replace(/^drafts\./, ""); + const studioUrl = `https://codingcat-prod.sanity.studio/intent/edit/id=${baseDocId};type=post/`; + const slugMatch = canonicalUrl.match(/codingcat\.dev\/(?:post|podcast|course)\/([a-z0-9-]+)/i); + const extractedSlug = slugMatch ? slugMatch[1] : ""; + const mobileHashnodeUrl = extractedSlug + ? `https://transcripts.codingcat.dev/hashnode/${extractedSlug}` + : "https://hashnode.com/draft/6adff331943e682eec05f06c"; + + // Put canonicalUrl and Sanity Studio link at the top so they are immediately clickable on the card const taskNotes = [ canonicalUrl, + `Studio: ${studioUrl}`, `Tags: ${tags.join(", ")}`, ].join("\n"); const subtasks = [ { - title: "3. Cross-post to Hashnode", - notes: `https://hashnode.com/draft\nCanonical URL: ${canonicalUrl}`, + title: "3. Cross-post to Hashnode (1-Tap Copy & Open)", + notes: `${mobileHashnodeUrl}\nRaw .md: ${mobileHashnodeUrl}.md\nDraft: https://hashnode.com/draft/6adff331943e682eec05f06c`, }, { title: "2. Import to Medium (1-Click)", diff --git a/scripts/run-trend-radar.mjs b/scripts/run-trend-radar.mjs index d5e92825..8b32c3d8 100644 --- a/scripts/run-trend-radar.mjs +++ b/scripts/run-trend-radar.mjs @@ -748,18 +748,33 @@ async function createGoogleTaskNotification(title, notes) { if (!tokenRes.ok) return; const { access_token } = await tokenRes.json(); - const taskRes = await fetch("https://tasks.googleapis.com/tasks/v1/lists/@default/tasks", { - method: "POST", - headers: { - Authorization: `Bearer ${access_token}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - title, - notes, - due: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), - }), + let targetListId = "@default"; + const listsRes = await fetch("https://tasks.googleapis.com/tasks/v1/users/@me/lists?maxResults=100", { + headers: { Authorization: `Bearer ${access_token}` }, }); + if (listsRes.ok) { + const listsData = await listsRes.json(); + const found = (listsData.items || []).find( + (l) => (l.title || "").trim().toLowerCase() === "codingcat.dev posts" + ); + if (found?.id) targetListId = found.id; + } + + const taskRes = await fetch( + `https://tasks.googleapis.com/tasks/v1/lists/${encodeURIComponent(targetListId)}/tasks`, + { + method: "POST", + headers: { + Authorization: `Bearer ${access_token}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title, + notes, + due: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), + }), + } + ); if (taskRes.ok) { console.log(`✓ Created Google Task: "${title}"`); } @@ -987,9 +1002,18 @@ async function runForDataset(targetDataset) { if (targetDataset === "production" && createdDraftInfo) { const { signal, draftDoc, socialDrafts } = createdDraftInfo; + const baseDraftId = String(draftDoc._id).replace(/^drafts\./, ""); + const studioDraftUrl = `https://codingcat-prod.sanity.studio/intent/edit/id=${baseDraftId};type=post/`; await createGoogleTaskNotification( `🔥 [Trend Radar] Review Draft: ${signal.title}`, - `Score: ${signal.score}/100 (${signal.rawMetrics})\nSource: ${signal.sourceUrl}\nSanity Draft ID: ${draftDoc._id}\n\nReady-to-post X Draft:\n${socialDrafts.x}` + [ + `Studio Draft: ${studioDraftUrl}`, + `Score: ${signal.score}/100 (${signal.rawMetrics})`, + `Source: ${signal.sourceUrl}`, + ``, + `Ready-to-post X Draft:`, + socialDrafts.x, + ].join("\n") ); } }