Merge pull request #69 from nurRiyad/riyad/rss-feed

Add rss feed
This commit is contained in:
Al Asad Nur Riyad
2024-10-02 21:59:45 +06:00
committed by GitHub
5 changed files with 4080 additions and 5179 deletions

View File

@@ -18,6 +18,8 @@ const path = computed(() => route.fullPath.replace('/', ''))
© 2020-2024 No Right is reserved. Who cares 🤷? It's © 2020-2024 No Right is reserved. Who cares 🤷? It's
<a href="https://github.com/nurriyad/blog" target="_blank" rel="nofollow" class="underline">open source</a> <a href="https://github.com/nurriyad/blog" target="_blank" rel="nofollow" class="underline">open source</a>
anyway. anyway.
<a href="/rss.xml"> <span class="px-3"><Icon name="bi:rss-fill" /></span></a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -16,6 +16,7 @@ export default defineNuxtConfig({
sitemap: { sitemap: {
strictNuxtContentPaths: true, strictNuxtContentPaths: true,
}, },
site: { site: {
url: seoData.mySite, url: seoData.mySite,
identity: { identity: {
@@ -33,6 +34,7 @@ export default defineNuxtConfig({
crawlLinks: true, crawlLinks: true,
routes: [ routes: [
'/', '/',
'/rss.xml',
], ],
}, },
}, },
@@ -62,4 +64,6 @@ export default defineNuxtConfig({
theme: 'dracula', theme: 'dracula',
}, },
}, },
compatibilityDate: '2024-09-30',
}) })

9215
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,10 +13,10 @@
"@antfu/eslint-config": "^0.42.0", "@antfu/eslint-config": "^0.42.0",
"@formkit/auto-animate": "^0.8.1", "@formkit/auto-animate": "^0.8.1",
"@nuxt/content": "^2.12.1", "@nuxt/content": "^2.12.1",
"@nuxt/image": "^1.7.0", "@nuxt/image": "^1.8.0",
"@nuxtjs/color-mode": "^3.3.2", "@nuxtjs/color-mode": "^3.3.2",
"@nuxtjs/fontaine": "^0.4.1", "@nuxtjs/fontaine": "^0.4.1",
"@nuxtjs/robots": "^3.0.0", "@nuxtjs/robots": "^4.1.7",
"@nuxtjs/sitemap": "^5.3.2", "@nuxtjs/sitemap": "^5.3.2",
"@nuxtjs/tailwindcss": "^6.11.4", "@nuxtjs/tailwindcss": "^6.11.4",
"@stefanobartoletti/nuxt-social-share": "^0.6.1", "@stefanobartoletti/nuxt-social-share": "^0.6.1",
@@ -25,7 +25,8 @@
"@vueuse/core": "^10.9.0", "@vueuse/core": "^10.9.0",
"@vueuse/nuxt": "^10.9.0", "@vueuse/nuxt": "^10.9.0",
"eslint": "^8.39.0", "eslint": "^8.39.0",
"nuxt": "^3.12.2", "feed": "^4.2.2",
"nuxt": "^3.13.2",
"nuxt-icon": "^0.6.8", "nuxt-icon": "^0.6.8",
"nuxt-og-image": "^3.0.0-rc.38", "nuxt-og-image": "^3.0.0-rc.38",
"typescript": "^5.3.3", "typescript": "^5.3.3",

37
server/routes/rss.xml.ts Normal file
View File

@@ -0,0 +1,37 @@
import { Feed } from 'feed'
import { serverQueryContent } from '#content/server'
const basePath = 'https://nurriyad.xyz'
export default defineEventHandler(async (event) => {
setHeader(event, 'content-type', 'text/xml')
const docs = await serverQueryContent(event).sort({ date: -1 }).find()
const feed = new Feed({
title: 'Riyad\'s personal blog site',
description: 'Riyad\'s personal blog site',
id: basePath,
link: basePath,
language: 'en',
favicon: `${basePath}/favicon.ico`,
copyright: 'MIT',
author: {
name: 'Al Asad Nur Riyad',
email: 'asadnurriyad@gmail.com',
link: basePath,
},
})
// Add the feed items
docs.forEach((doc) => {
feed.addItem({
title: doc.title || '',
id: basePath + doc._path,
link: basePath + doc._path,
description: doc.description,
content: doc.description,
date: new Date(doc.date),
})
})
return feed.rss2()
})