diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index bdd91f8..bad2aa2 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -17,6 +17,8 @@ FROM node:22-slim WORKDIR /app +COPY ./articles ./articles + COPY --from=builder /app/build ./build COPY --from=builder /app/package.json . COPY --from=builder /app/node_modules ./node_modules diff --git a/src/lib/page/article_page.svelte b/src/lib/page/article_page.svelte index 57dfe73..109f79e 100644 --- a/src/lib/page/article_page.svelte +++ b/src/lib/page/article_page.svelte @@ -7,7 +7,7 @@ import FormattedDate from '$lib/components/formatted_date.svelte'; import Head from '$lib/components/head.svelte'; - import type { Article } from '$lib/article'; + import type { Article } from '$lib/article'; export let data: Article; @@ -31,38 +31,49 @@ -->
-
-

{data.title}

-
- - released - {#if data.updated_at}
- updated - {/if} -
- - {data.category[0].toUpperCase() + data.category.slice(1)} - {#each data.tags as tag} - {tag} - {/each} - +
+
+

{data.title}

+
+ + released + {#if data.updated_at}
+ updated + {/if} +
+ + {data.category[0].toUpperCase() + data.category.slice(1)} + {#each data.tags as tag} + {tag} + {/each} + +
-
-
-
+
-
-
-
+
+
diff --git a/src/lib/server/database.ts b/src/lib/server/database.ts index e8bcae5..88aa140 100644 --- a/src/lib/server/database.ts +++ b/src/lib/server/database.ts @@ -1,5 +1,5 @@ import pg from 'pg'; -import { Pool } from 'pg'; +const { Pool } = pg; import { getConnection } from './database/get_connection'; export class Postgres { diff --git a/src/lib/server/database/init_db.ts b/src/lib/server/database/init_db.ts index 45ef903..1964187 100644 --- a/src/lib/server/database/init_db.ts +++ b/src/lib/server/database/init_db.ts @@ -1,5 +1,4 @@ // initialize -import PG from '$lib/server/database'; import type { Postgres } from '$lib/server/database'; import fs from 'fs'; import { compile } from 'mdsvex'; @@ -108,6 +107,7 @@ export default async function init(db: Postgres) { for (const { path, id } of articleFiles) { const res = await db.query('select * from article where id = $1', [id]); const compiled = await compile(fs.readFileSync(path, 'utf-8')); + const title = compiled.data.fm.title; const category = path.split('/')[3]; const tags: string[] = compiled.data.fm.tags; @@ -127,8 +127,8 @@ export default async function init(db: Postgres) { } else if (res.rows[0].updated_at < updated_at) { console.log(`Update article: ${id}`); await db.query( - 'update article set title = $2, updated_at = $4, tags = $5, content = $6 where id = $1', - [id, title, updated_at, tags, content] + 'update article set title = $2, category = $3, released_at = $4, updated_at = $5, tags = $6, image = $7, publish = $8, content = $9 where id = $1', + [id, title, category, released_at, updated_at, tags, image, publish, content] ); } else { console.log(`Article ${id} is already up-to-date`); diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index 2dcd548..ab3d7ca 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -41,7 +41,10 @@