Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
7038e47c75 | |||
5681454b61 | |||
23a01e782a | |||
7ad780be6c | |||
2c42f24d0f |
4 changed files with 62 additions and 13 deletions
|
@ -48,24 +48,13 @@ const firstTen = computed<BlogCard[]>(() => {
|
||||||
return (articles.value?.slice(0, 10) ?? []).map(makeBlogCard)
|
return (articles.value?.slice(0, 10) ?? []).map(makeBlogCard)
|
||||||
})
|
})
|
||||||
|
|
||||||
const allCategoriesAndCount = computed<Record<Category, number>>(() => {
|
|
||||||
const categories = {} as Record<Category, number>
|
|
||||||
articles.value?.forEach(article => {
|
|
||||||
const category = article.category as Category
|
|
||||||
if (category) {
|
|
||||||
categories[category] = (categories[category] ?? 0) + 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return categories
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data: externalPostsRaw } = useFetch('/api/external-posts', { method: 'POST' })
|
const { data: externalPostsRaw } = useFetch('/api/external-posts', { method: 'POST' })
|
||||||
|
|
||||||
const externalPosts = computed<BlogCard[]>(() => externalPostsRaw.value?.flatMap(externalBlog => {
|
const externalPosts = computed<BlogCard[]>(() => externalPostsRaw.value?.flatMap(externalBlog => {
|
||||||
return externalBlog.posts.map(post => ({
|
return externalBlog.posts.map(post => ({
|
||||||
title: post.title,
|
title: post.title,
|
||||||
description: post.excerpt,
|
description: post.excerpt,
|
||||||
image: post['og-image'],
|
image: post.thumbnail,
|
||||||
date: post.date,
|
date: post.date,
|
||||||
link: post.url,
|
link: post.url,
|
||||||
category: 'extern',
|
category: 'extern',
|
||||||
|
@ -75,6 +64,18 @@ const externalPosts = computed<BlogCard[]>(() => externalPostsRaw.value?.flatMap
|
||||||
|
|
||||||
const allPosts = computed<BlogCard[]>(() => [...(firstTen.value ?? []), ...(externalPosts.value ?? [])].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()))
|
const allPosts = computed<BlogCard[]>(() => [...(firstTen.value ?? []), ...(externalPosts.value ?? [])].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()))
|
||||||
|
|
||||||
|
const allCategoriesAndCount = computed<Record<Category, number>>(() => {
|
||||||
|
const categories = {} as Record<Category, number>
|
||||||
|
articles.value?.forEach(article => {
|
||||||
|
const category = article.category as Category
|
||||||
|
if (category) {
|
||||||
|
categories[category] = (categories[category] ?? 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
categories['extern'] = externalPosts.value?.length ?? 0
|
||||||
|
return categories
|
||||||
|
})
|
||||||
|
|
||||||
const makeBlogCard = (article: BlogCollectionItem): BlogCard => ({
|
const makeBlogCard = (article: BlogCollectionItem): BlogCard => ({
|
||||||
title: article.title,
|
title: article.title,
|
||||||
description: article.description,
|
description: article.description,
|
||||||
|
|
47
docker-compose.yaml
Normal file
47
docker-compose.yaml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
wf4:
|
||||||
|
image: oven/bun:latest
|
||||||
|
container_name: wf4
|
||||||
|
working_dir: /app
|
||||||
|
ports:
|
||||||
|
- "1337:3000"
|
||||||
|
volumes:
|
||||||
|
- wf4_data:/app
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
command: >
|
||||||
|
sh -c "
|
||||||
|
# Install git and curl if not already installed
|
||||||
|
if ! command -v git &> /dev/null || ! command -v curl &> /dev/null; then
|
||||||
|
echo 'Installing required packages...'
|
||||||
|
apt-get update && apt-get install -y git curl
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
# Clone repository if not already cloned
|
||||||
|
if [ ! -d /app/.git ]; then
|
||||||
|
echo 'Cloning repository...'
|
||||||
|
git clone https://git.webfussel.de/webfussel/wf4 /tmp/wf4 &&
|
||||||
|
cp -r /tmp/wf4/. /app/ &&
|
||||||
|
rm -rf /tmp/wf4
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
# Install dependencies and start application
|
||||||
|
echo 'Installing dependencies...' &&
|
||||||
|
bun install &&
|
||||||
|
echo 'Building application...' &&
|
||||||
|
bun run build &&
|
||||||
|
echo 'Starting application...' &&
|
||||||
|
bun .output/server/index.mjs
|
||||||
|
"
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:1337"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
wf4_data:
|
1
server/api/health.get.ts
Normal file
1
server/api/health.get.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default defineEventHandler((): string => 'ok' )
|
|
@ -3,7 +3,7 @@ export type Post = {
|
||||||
title: string
|
title: string
|
||||||
excerpt: string
|
excerpt: string
|
||||||
date: string
|
date: string
|
||||||
'og-image': string
|
thumbnail: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Author = {
|
type Author = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue