Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
thilobillerbeck committed Dec 24, 2024
2 parents 0fe91b5 + c482266 commit 6ab20a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/bluesky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ export async function generateBlueskyPostFromMastodon(content: string, client: A
if (media_attachmentsFiltered.length > 0 && client) {
const images: {
image: BlobRef,
alt: string
alt: string,
aspectRatio: {
width: number,
height: number,
}
}[] = [];
for (const media of media_attachmentsFiltered) {
const {arrayBuffer, mimeType} = await fetchImageToBytes(media.url)
Expand All @@ -158,6 +162,10 @@ export async function generateBlueskyPostFromMastodon(content: string, client: A
images.push({
image: res.data.blob,
alt: media.description ? media.description : '',
aspectRatio: {
width: media.meta.width || media.meta.original.width,
height: media.meta.height || media.meta.original.height,
}
});
}

Expand Down
6 changes: 6 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export function mastodonHtmlToText(html: string) {
hashtag.remove()
}

const links = root.querySelectorAll('a')
for (const link of links) {
link.replaceWith(`<span> ${link.attributes.href} </span>`)
link.remove()
}

root.removeWhitespace()

return convert(root.toString(), {
Expand Down

0 comments on commit 6ab20a4

Please sign in to comment.