Skip to content

Commit

Permalink
Only extract html (#26)
Browse files Browse the repository at this point in the history
* Update astro

* Fix recent article statement, again

* Only extract html
  • Loading branch information
carterworks authored Jan 14, 2025
1 parent 5075872 commit 938b5e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/services/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
4 changes: 4 additions & 0 deletions src/services/clipper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ async function fetchPage(url: URL): Promise<JSDOM> {
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 = [
Expand Down

0 comments on commit 938b5e4

Please sign in to comment.