diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 18:23:00 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-03 18:23:00 +0300 |
| commit | 78461649639dba10f9ade8b1dba9e8f2c69a4144 (patch) | |
| tree | fc89a83ecc5c8500c77ebc359fd7b7b2b42f085b /src/loaders | |
| parent | 0df973de7b554008383a23fd4fc2a0b8e1401b37 (diff) | |
Add husky pre-commit
Diffstat (limited to 'src/loaders')
| -rw-r--r-- | src/loaders/pleroma.ts | 29 |
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({ |
