mirror of
https://github.com/fmhy/edit.git
synced 2026-02-18 09:11:33 +11:00
improve
This commit is contained in:
parent
c7f6b4a0be
commit
a290a25c8e
1 changed files with 27 additions and 26 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { writeFileSync } from 'node:fs'
|
import { writeFileSync } from 'node:fs'
|
||||||
import { Feed } from 'feed'
|
import { Feed } from 'feed'
|
||||||
import {
|
import { createContentLoader, type ContentData, type SiteConfig } from 'vitepress'
|
||||||
createContentLoader,
|
|
||||||
type ContentData,
|
|
||||||
type SiteConfig
|
|
||||||
} from 'vitepress'
|
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { meta } from '../constants'
|
import { meta } from '../constants'
|
||||||
|
|
||||||
|
|
@ -21,6 +17,7 @@ export async function generateFeed(config: SiteConfig): Promise<void> {
|
||||||
copyright: `Copyright (c) 2023-present FMHY`
|
copyright: `Copyright (c) 2023-present FMHY`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
const posts: ContentData[] = await createContentLoader('posts/*.md', {
|
const posts: ContentData[] = await createContentLoader('posts/*.md', {
|
||||||
excerpt: true,
|
excerpt: true,
|
||||||
render: true,
|
render: true,
|
||||||
|
|
@ -45,5 +42,9 @@ export async function generateFeed(config: SiteConfig): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileSync(path.join(config.outDir, 'feed.rss'), feed.rss2())
|
writeFileSync(path.join(config.outDir, 'feed.rss'), feed.rss2())
|
||||||
return consola.info('Generated rss feed.')
|
console.log('Generated rss feed.')
|
||||||
|
} catch (error) {
|
||||||
|
consola.error('Error generating rss feed:', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue