Yatxatapxañani kunjamasa programaticamente apsuña ukhamaraki uñt’ayaña munata Bluesky qillqatanakaxa chiqapa uñt’ayawi, API jawsatanaka, ukhamaraki oEmbed tukuyañanakampi.
Jichhakiw Bluesky ukar sarxawayta. Nayax nayratpach chiqanchañjamawa, ukanx mä ch’amanchata comunidad tecnológica ukaw utji, toneladas de contenidos interesantes, útiles ukat inspiradores ukanakampi. ¡Nayax mä kusisit machaq apnaqiritwa! Ukhamatwa, Bluesky ukan wali munat qillqatanakax "Dev roundup" phaxsi yatiyäw qillqatanakanx uñt'ayañ munta. Nayan amtäwijasti mä lista curada Bluesky ukan qillqatanakap uñt’ayañawa, ukax Software Developers ukar uñt’ayatawa.
Suertenixa, Bluesky ukan API ukax taqpach apnaqañapatakix inakiw, ukax programatico ukar mantañapatakiw taqi kunatix ukan utjki ukanakar mantañapataki. Aka yatichäwix Bluesky ukan munat qillqatanakap API apnaqañamp apsuñ ukhamarak uñt’ayañ thakhinjam irpapxätam, blogs personales, carteras jan ukax proyectos de agregación de contenidos ukanakatakix wali askiwa.
Nayax mä script lurawayta, ukax Bluesky ukan qillqatanakax mä markdown blog post ukar automáticamente uñt’ayañatakiw yanapt’itu. Nayax amuyta, kawkir jan ukax taqpach lurawinakas aka script ukan apnaqatäki ukax walja apnaqañ-caso ukanakatakix wali askiwa.
Nayan lurawix mä juk’a qhanañcht’añatakix gustat posts ukanakar uñt’ayañatakix aka jach’a lurawinakampiw arktasipxta:
Sapa lurawi ukhamaraki kuna amtampis lurasi ukxat t’aqanuqt’añäni:
export const createSession = async (): Promise<string | null> => { try { const response = await fetch( "https://bsky.social/xrpc/com.atproto.server.createSession", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ identifier: "your-handle", password: "your-password", }), } ); const responseJson = await response.json(); return responseJson.accessJwt; } catch (e) { console.error("Failed to create session: ", e); return null; } };
Jach’a amuyunaka:
accessJwt
JWT (JSON Web Token) ukaruw kutt’ayaraki, qhipa API jawsatanakatakicreateSession
tukuyañ chimpu apnaqi . export const getBlueskyLikeUris = async (actor: string, limit: number = 40) => { const token = await createSession(); if (!token) { console.error("Failed to get token"); return; } const response = await fetch( "https://bsky.social/xrpc/app.bsky.feed.getActorLikes?actor=${actor}&limit=${limit}", { method: "GET", headers: { Authorization: `Bearer ${token}`, }, } ); const responseJson = await response.json(); const uris = responseJson.feed.map((entry: any) => entry.post.uri); return uris; };
Jach’a amuyunaka:
getActorLikes
ukax wali askiwa export const getBlueskyPostEmbedMarkup = async (uri: string) => { try { const response = await fetch(`https://embed.bsky.app/oembed?url=${uri}`); const responseJson = await response.json(); const formattedHTML = prettier.format(responseJson.html, { parser: "html", plugins: [require("prettier/parser-html")], htmlWhitespaceSensitivity: "ignore", printWidth: 1000, }); return formattedHTML.replace(/<script[\s\S]*?<\/script>/g, ""); } catch (e) { console.error("Failed to get Bluesky post embed markup"); return null; } };
Jach’a amuyunaka:
prettier
ukax HTML ukax formato constante ukhamawa<script>
chimpunak apsuña seguridad ukat q’uma uñt’ayañataki async function embedLikedPosts() { try { // Get liked post URIs const likedPostUris = await getBlueskyLikeUris(); if (!likedPostUris) { console.error("No liked posts found"); return; } // Convert URIs to embed HTML const embedPromises = likedPostUris.map(getBlueskyPostEmbedMarkup); const embedHtmlArray = await Promise.all(embedPromises); // Filter out any failed embeds const validEmbeds = embedHtmlArray.filter(embed => embed !== null); // Return the markup for all liked posts return ` ## Some Fave Posts 🦋 ${validEmbeds.join(`\n\n`)} ` } catch (error) { console.error("Error embedding Bluesky posts:", error); } }
Aka solución ukax nayatakix irnaqaskiw kunatix taqi kunatix nayatakix wakiski ukax mä post blog ukan sapa phaxsi estáticamente generado ukawa.
Mä qhawqha askinak lurañax akanakawa:
accessJwt
token ukar machaqar tukuyañataki, ukax jaya pachan lurawinakan apnaqatawaBluesky ukan qillqatanakap uñt’ayañax mä ch’amanchawiw medios sociales ukan mayacht’asiwinakap uñacht’ayañataki. API irnaqawi amuyt’asa ukhamaraki ch’amani pantjasiwi apnaqawi phuqhasa, ukaxa lurasispawa, ukaxa lurasispawa, ukaxa mä juk’a pachanakwa lurasirakispa.
¡Kusisiña ukat kusisita tinkering! 🚀