diff --git a/Dockerfile b/Dockerfile
index cf93fb9..14b7f2b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,23 +1,15 @@
-FROM node:16
-
+FROM node:16-alpine
# install dependencies
WORKDIR /app
-COPY package.json package-lock.json ./
-RUN pnpm install
-
-# Copy all local files into the image.
+RUN npm install -g pnpm
COPY . .
-
+RUN pnpm install
RUN pnpm build
-
-###
-# Only copy over the Node pieces we need
-# ~> Saves 35MB
-###
-FROM node:16-slim
-
+FROM node:16-alpine
WORKDIR /app
-COPY --from=0 /app/build .
+COPY --from=0 /app/build /app
+COPY --from=0 /app/package.json /app
+COPY --from=0 /app/node_modules /app/node_modules
EXPOSE 3000
-CMD ["node", "./index.js"]
+CMD ["node","./index.js"]
diff --git a/package.json b/package.json
index 817b304..62b2c9e 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
},
"type": "module",
"dependencies": {
- "@damillora/plachta": "^1.0.0",
+ "@damillora/plachta": "^1.2.0",
"@tryghost/content-api": "^1.11.0",
"fitvids": "^2.1.1",
"svelte-material-icons": "^2.0.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2026164..01639d9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,7 +1,7 @@
lockfileVersion: 5.3
specifiers:
- '@damillora/plachta': ^1.0.0
+ '@damillora/plachta': ^1.2.0
'@sveltejs/adapter-auto': next
'@sveltejs/adapter-node': ^1.0.0-next.83
'@sveltejs/kit': next
@@ -30,7 +30,7 @@ specifiers:
vite: ^3.0.2
dependencies:
- '@damillora/plachta': 1.0.0_svelte@3.49.0
+ '@damillora/plachta': 1.2.0_svelte@3.49.0
'@tryghost/content-api': 1.11.0
fitvids: 2.1.1
svelte-material-icons: 2.0.2_svelte@3.49.0
@@ -66,8 +66,8 @@ packages:
resolution: {integrity: sha512-B1/plF62pt+H2IJHvApK8fdOJAVsvojvacuac8x8s+JIyqbropMyqNqHTKLm3YD8ZFLGwYeFTudU+PQ7vGvBdA==}
dev: true
- /@damillora/plachta/1.0.0_svelte@3.49.0:
- resolution: {integrity: sha512-ZOwMptEOhI0fBOe40p8PJVjV3b78yg6HoW3e/PaKND+fXtvOTbFnDZGfCPcMOD+pKRZm9G5X7AygqJ9atn0rfA==}
+ /@damillora/plachta/1.2.0_svelte@3.49.0:
+ resolution: {integrity: sha512-DDXojXmmyUS6tX4dgv8eirAU8R13fzHhcX/VoRRf8kfEpwPLqkAVto7qCdfveN0/Q3t/IqX0AKiFCdCfRI50wA==}
dependencies:
svelte-material-icons: 2.0.2_svelte@3.49.0
svelte-themes: 0.0.98
diff --git a/src/lib/components/SEO/PostSEO.svelte b/src/lib/components/SEO/PostSEO.svelte
index 2401c22..2a85210 100644
--- a/src/lib/components/SEO/PostSEO.svelte
+++ b/src/lib/components/SEO/PostSEO.svelte
@@ -1,7 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{@html schemaOrg}
diff --git a/src/lib/content/contentApi.ts b/src/lib/content/contentApi.ts
index 8f7415b..3b96198 100644
--- a/src/lib/content/contentApi.ts
+++ b/src/lib/content/contentApi.ts
@@ -32,21 +32,32 @@ export const browsePostWithAuthor = async (slug: string, page = 1) => {
return posts
}
export const readPost = async (slug: string) => {
- const post = await api.posts.read({ slug }, { include: ['tags', 'authors'] });
-
- return post;
+ try {
+ const post = await api.posts.read({ slug }, { include: ['tags', 'authors'] });
+
+ return post;
+ } catch (e) {
+ return null;
+ }
}
export const readTag = async (slug: string) => {
- const tag = await api.tags.read({ slug });
-
- return tag;
+ try {
+ const tag = await api.tags.read({ slug });
+
+ return tag;
+ } catch (e) {
+ return null;
+ }
}
export const readAuthor = async (slug: string) => {
- const author = await api.authors.read({ slug });
-
- return author;
+ try {
+ const author = await api.authors.read({ slug });
+ return author;
+ } catch (e) {
+ return null;
+ }
}
export const browseLatestPost = async () => {
diff --git a/src/routes/[tag]/[slug].svelte b/src/routes/[tag]/[slug].svelte
index e1a80c9..6272391 100644
--- a/src/routes/[tag]/[slug].svelte
+++ b/src/routes/[tag]/[slug].svelte
@@ -1,13 +1,18 @@
@@ -26,7 +31,7 @@
import type { Load } from '@sveltejs/kit';
import { readPost } from '$lib/content/contentApi';
import { browser } from '$app/env';
-import PostSeo from '$lib/components/SEO/PostSEO.svelte';
+ import PostSeo from '$lib/components/SEO/PostSEO.svelte';
export let post: any;
@@ -39,7 +44,7 @@ import PostSeo from '$lib/components/SEO/PostSEO.svelte';
{post.title}
-
+
diff --git a/src/routes/[tag]/index.svelte b/src/routes/[tag]/index.svelte
index 9086e5f..2f986b6 100644
--- a/src/routes/[tag]/index.svelte
+++ b/src/routes/[tag]/index.svelte
@@ -1,15 +1,22 @@
diff --git a/src/routes/author/[author].svelte b/src/routes/author/[author].svelte
index 87bc8a9..a996195 100644
--- a/src/routes/author/[author].svelte
+++ b/src/routes/author/[author].svelte
@@ -2,6 +2,14 @@
export const load: Load = async ({ params }) => {
const authorSlug = params.author;
const authorObj = await readAuthor(authorSlug);
+
+ if (!authorObj) {
+ return {
+ status: 404,
+ error: new Error('Author not found')
+ };
+ }
+
const posts = await browsePostWithAuthor(authorSlug);
return {
diff --git a/svelte.config.js b/svelte.config.js
index ce4ff82..624e0ae 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -8,7 +8,7 @@ const config = {
preprocess: preprocess(),
kit: {
- adapter: adapter()
+ adapter: adapter(),
}
};
diff --git a/vite.config.js b/vite.config.js
index a575398..e60c19b 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -5,6 +5,8 @@ import preprocess from 'svelte-preprocess';
const config = {
plugins: [sveltekit({
useVitePreprocess: true,
+
+ noExternal: ['dayjs']
})],
};