summaryrefslogtreecommitdiff
path: root/src/loaders/pleroma.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/loaders/pleroma.ts')
-rw-r--r--src/loaders/pleroma.ts29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/loaders/pleroma.ts b/src/loaders/pleroma.ts
index feb11c8..952e491 100644
--- a/src/loaders/pleroma.ts
+++ b/src/loaders/pleroma.ts
@@ -1,7 +1,7 @@
import type { Loader } from "astro/loaders";
import { XMLParser } from "fast-xml-parser";
-import TurndownService from "turndown";
import { marked } from "marked";
+import TurndownService from "turndown";
interface PleromaFeedConfig {
instanceUrl: string;
@@ -199,12 +199,12 @@ function markdownToHtml(markdown: string): string {
breaks: true, // Convert line breaks to <br>
gfm: true, // GitHub flavored markdown
});
-
+
// Convert markdown to HTML
const html = marked.parse(markdown);
-
+
// Return as string (marked.parse can return string or Promise<string>)
- return typeof html === 'string' ? html : '';
+ return typeof html === "string" ? html : "";
}
function extractTitle(content: string): string {
@@ -259,7 +259,7 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
if (response.ok) {
break; // Success, exit retry loop
}
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
} catch (error) {
lastError = error;
logger.warn(`Attempt ${attempt} failed: ${error}`);
@@ -312,16 +312,19 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader {
const postId = entry.id.split("/").pop() || entry.id;
// Extract source URL from the entry
- const sourceUrl = entry.link?.find(link => link["@_rel"] === "alternate")?.["@_href"] || entry.id;
+ 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"]
- })) || [];
+ 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({