diff --git a/bun.lockb b/bun.lockb index 8610126..19e47e2 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 37943af..fc1e089 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,13 @@ "dependencies": { "@ai-sdk/openai": "^0.0.48", "@astrojs/check": "^0.9.4", - "@astrojs/node": "^9.0.0", - "@astrojs/tailwind": "^5.1.3", + "@astrojs/node": "9.0.1", + "@astrojs/tailwind": "5.1.4", "@iconify-json/lucide": "^1.2.10", "@mozilla/readability": "^0.5.0", "@tailwindcss/typography": "^0.5.13", "ai": "^3.3.9", - "astro": "^5.0.1", + "astro": "5.1.6", "astro-icon": "^1.1.1", "dompurify": "^3.1.6", "jsdom": "^24.1.1", diff --git a/src/services/cache.ts b/src/services/cache.ts index e57c403..b517ccb 100644 --- a/src/services/cache.ts +++ b/src/services/cache.ts @@ -68,7 +68,10 @@ class CacheService { this.#getRecentArticlesStatement = db.query< SerializedReadablePage, { limit: number } - >("SELECT * FROM articles ORDER BY createdAt, published DESC LIMIT :limit"); + >(`SELECT * FROM articles + ORDER BY + CASE WHEN createdAt IS NULL THEN published ELSE createdAt END DESC + LIMIT :limit`); console.log( "CacheService initialized [article count: %d]", diff --git a/src/services/clipper.ts b/src/services/clipper.ts index 6adde08..c47fd60 100644 --- a/src/services/clipper.ts +++ b/src/services/clipper.ts @@ -15,6 +15,10 @@ async function fetchPage(url: URL): Promise { if (!response.ok) { throw new Error(`Failed to fetch ${url.toString()}`); } + const contentType = response.headers.get("content-type"); + if (!contentType || !contentType.includes("text/html")) { + throw new Error(`URL "${url.toString()}" is not an HTML page`); + } const page = new JSDOM(await response.text(), { url: url.toString() }); // force lazy-loaded images to load const LAZY_DATA_ATTRS = [