summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/note/Note.astro21
-rw-r--r--src/loaders/pleroma.ts14
2 files changed, 35 insertions, 0 deletions
diff --git a/src/components/note/Note.astro b/src/components/note/Note.astro
index a8cf205..3017d2d 100644
--- a/src/components/note/Note.astro
+++ b/src/components/note/Note.astro
@@ -45,6 +45,27 @@ const { Content } = await render(note);
>
<Content />
{
+ !isPreview && note.data.attachments && note.data.attachments.length > 0 && (
+ <div class="mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2">
+ {note.data.attachments.map((attachment: { url: string; type: string }) => (
+ <a
+ href={attachment.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="block overflow-hidden rounded-lg border border-gray-200 transition-colors hover:border-gray-300 dark:border-gray-700 dark:hover:border-gray-600"
+ >
+ <img
+ src={attachment.url}
+ alt="Attachment"
+ class="h-48 w-full object-cover"
+ loading="lazy"
+ />
+ </a>
+ ))}
+ </div>
+ )
+ }
+ {
!isPreview && note.data.sourceUrl && (
<>
<hr class="mt-6 mb-4 border-t border-gray-300 dark:border-gray-600" />
diff --git a/src/loaders/pleroma.ts b/src/loaders/pleroma.ts
index a0b169f..feb11c8 100644
--- a/src/loaders/pleroma.ts
+++ b/src/loaders/pleroma.ts
@@ -314,6 +314,15 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
// Extract source URL from the entry
const sourceUrl = entry.link?.find(link => link["@_rel"] === "alternate")?.["@_href"] || entry.id;
+ // Extract image attachments
+ const attachments = entry.link?.filter(link =>
+ link["@_rel"] === "enclosure" &&
+ link["@_type"]?.startsWith("image/")
+ ).map(link => ({
+ url: link["@_href"],
+ type: link["@_type"]
+ })) || [];
+
// Create note entry
store.set({
id: `pleroma-${postId}`,
@@ -323,6 +332,7 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
cleanedContent.substring(0, 160) + (cleanedContent.length > 160 ? "..." : ""),
publishDate: new Date(entry.published),
sourceUrl,
+ attachments,
},
body: cleanedContent,
rendered: {
@@ -363,6 +373,9 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
// Use the link as source URL
const sourceUrl = typeof item.link === "string" ? item.link : item.guid || "";
+ // For RSS, attachments would be empty since we're actually getting Atom feeds
+ const attachments: { url: string; type: string }[] = [];
+
// Create note entry
store.set({
id: `pleroma-${postId}`,
@@ -372,6 +385,7 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
cleanedContent.substring(0, 160) + (cleanedContent.length > 160 ? "..." : ""),
publishDate: new Date(item.pubDate),
sourceUrl,
+ attachments,
},
body: cleanedContent,
rendered: {