This commit is contained in:
2025-07-18 16:43:10 +02:00
parent ad40616249
commit 8c37084d94
94 changed files with 14759 additions and 0 deletions

13
src/pages/404.astro Normal file
View File

@@ -0,0 +1,13 @@
---
import { themeConfig } from '@/config'
import IndexLayout from '@/layouts/IndexLayout.astro'
---
<IndexLayout title={`404 - ${themeConfig.site.title}`} description="Not Found">
<style>
.error-container {
color: var(--text-secondary);
}
</style>
<p class="error-container">Page Not Found...</p>
</IndexLayout>

26
src/pages/[...slug].astro Normal file
View File

@@ -0,0 +1,26 @@
---
import { type CollectionEntry, getCollection } from 'astro:content'
import PostLayout from '@/layouts/PostLayout.astro'
import { render } from 'astro:content'
export async function getStaticPaths() {
const posts = await getCollection('posts')
return posts
.filter((post) => !post.id.startsWith('_'))
.map((post) => ({
params: { slug: post.id },
props: post
}))
}
type Props = CollectionEntry<'posts'>
const post = Astro.props
const { Content, remarkPluginFrontmatter } = await render(post)
const readingTime = remarkPluginFrontmatter.readingTime
const toc = remarkPluginFrontmatter.toc || []
---
<PostLayout {...post.data} readingTime={readingTime} toc={toc}>
<Content />
</PostLayout>

33
src/pages/api/proxy.ts Normal file
View File

@@ -0,0 +1,33 @@
export const prerender = false
import type { APIContext } from 'astro'
export async function GET(context: APIContext) {
const host = context.request.headers.get('host') || 'localhost:4321'
const url = new URL(context.request.url, `http://${host}`)
const target = url.searchParams.get('url')
if (!target) {
return new Response('Missing url param', { status: 400 })
}
try {
const res = await fetch(target, {
headers: {
'User-Agent': 'Mozilla/5.0'
}
})
const contentType = res.headers.get('content-type') || 'text/html'
const data = await res.text()
return new Response(data, {
status: 200,
headers: {
'Content-Type': contentType,
'Cache-Control': 'no-store',
'Access-Control-Allow-Origin': '*'
}
})
} catch {
return new Response('Proxy error', { status: 500 })
}
}

6
src/pages/atom.xml.ts Normal file
View File

@@ -0,0 +1,6 @@
import type { APIContext } from 'astro'
import { generateAtom } from '@/utils/feed'
export async function GET(context: APIContext) {
return generateAtom(context)
}

16
src/pages/index.astro Normal file
View File

@@ -0,0 +1,16 @@
---
import IndexLayout from '@/layouts/IndexLayout.astro'
import About from '@/components/widgets/About.astro'
import PostList from '@/components/widgets/PostList.astro'
import { themeConfig } from '@/config'
import { getSortedFilteredPosts } from '@/utils/draft'
const posts = await getSortedFilteredPosts()
---
<IndexLayout title={themeConfig.site.title} description={themeConfig.site.description}>
<About />
<main>
<PostList posts={posts} />
</main>
</IndexLayout>

View File

@@ -0,0 +1,49 @@
import { getCollection } from 'astro:content'
import { OGImageRoute } from 'astro-og-canvas'
import { themeConfig } from '../../config'
const collectionEntries = await getCollection('posts')
// Map the array of content collection entries to create an object.
// Converts [{ id: 'post.md', data: { title: 'Example', pubDate: Date } }]
// to { 'post.md': { title: 'Example', pubDate: Date } }
const pages = Object.fromEntries(
collectionEntries.map(({ id, data }) => [id.replace(/\.(md|mdx)$/, ''), data])
)
export const { getStaticPaths, GET } = OGImageRoute({
param: 'route',
pages,
getImageOptions: (_path, page) => ({
title: page.title,
description: themeConfig.site.title,
logo: {
path: 'public/og/og-logo.png',
size: [80, 80]
},
bgGradient: [[255, 255, 255]],
bgImage: {
path: 'public/og/og-bg.png',
fit: 'fill'
},
padding: 64,
font: {
title: {
color: [28, 28, 28],
size: 68,
weight: 'SemiBold',
families: ['Inter']
},
description: {
color: [180, 180, 180],
size: 40,
weight: 'Medium',
families: ['Inter']
}
},
fonts: [
'https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-600-normal.ttf',
'https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-500-normal.ttf'
]
})
})

6
src/pages/rss.xml.ts Normal file
View File

@@ -0,0 +1,6 @@
import type { APIContext } from 'astro'
import { generateRSS } from '@/utils/feed'
export async function GET(context: APIContext) {
return generateRSS(context)
}