diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index b135e82..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: kaivanwong diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 99db40c..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: CI - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set node - uses: actions/setup-node@v3 - with: - node-version: lts/* - - - name: Install dependencies - run: npm install - - - name: Lint - run: npm run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 68e4a7f..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' - -jobs: - release: - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-node@v3 - with: - node-version: lts/* - - - run: npx changelogiter - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/astro.config.ts b/astro.config.ts index 4621b3c..8520d46 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -5,7 +5,7 @@ import UnoCSS from 'unocss/astro' import vue from '@astrojs/vue' export default defineConfig({ - site: 'https://astro-theme-vitesse.netlify.app/', + site: 'https://baalajimaestro.ptr.moe', server: { port: 1977, }, diff --git a/package.json b/package.json index 47ab582..61f1754 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,9 @@ "simple-git-hooks": "^2.11.1" }, "simple-git-hooks": { - "pre-commit": "npx lint-staged" + "pre-commit": "pnpm lint-staged" }, "lint-staged": { - "*": "npm run lint:fix" + "*": "pnpm lint:fix" } } diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index f731ddb..7cae840 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -1,26 +1,40 @@ -import rss from '@astrojs/rss' -import siteConfig from '@/site-config' -import { getPosts } from '@/utils/posts' +import rss from '@astrojs/rss'; +import siteConfig from '@/site-config'; +import { api } from '@/utils/ghost' interface Context { - site: string + site: string; +} + +// Function to strip HTML tags +function stripHtml(html: string) { + return html.replace(/<\/?[^>]+(>|$)/g, ""); } export async function GET(context: Context) { - const posts = await getPosts() + try { + // Fetch posts from Ghost + const posts = await api.posts.browse({ + limit: 'all', + include: ['tags', 'authors'], + fields: ['id', 'title', 'slug', 'published_at', 'custom_excerpt', 'html'] + }); - return rss({ - title: siteConfig.title, - description: siteConfig.description, - site: context.site, - items: posts!.map((item) => { - return { - ...item.data, - link: `${context.site}/posts/${item.slug}/`, - pubDate: new Date(item.data.date), - content: item.body, - author: `${siteConfig.author} <${siteConfig.email}>`, - } - }), - }) -} + return rss({ + title: siteConfig.title, + description: siteConfig.description, + site: context.site, + items: posts.map((post) => ({ + title: post.title, + description: post.custom_excerpt ? stripHtml(post.custom_excerpt) : '', + link: `${context.site}posts/${post.slug}/`, + pubDate: new Date(post.published_at), + content: stripHtml(post.html), + author: post.primary_author ? post.primary_author.name : siteConfig.author, + })), + }); + } catch (error) { + console.error('Error generating RSS feed:', error); + return new Response('Error generating RSS feed', { status: 500 }); + } +} \ No newline at end of file diff --git a/src/utils/posts.ts b/src/utils/posts.ts deleted file mode 100644 index 0e7de2e..0000000 --- a/src/utils/posts.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getCollection } from 'astro:content' -import type { CollectionPosts, PostKey } from '@/types' - -export function sortPostsByDate(itemA: CollectionPosts, itemB: CollectionPosts) { - return new Date(itemB.data.date).getTime() - new Date(itemA.data.date).getTime() -} - -export async function getPosts(path?: string, collection: PostKey = 'blog') { - return (await getCollection(collection, (post) => { - return (import.meta.env.PROD ? post.data.draft !== true : true) && (path ? post.slug.includes(path) : true) - })).sort(sortPostsByDate) -}