mirror of
https://github.com/andatoshiki/toshiki-notebook.git
synced 2026-06-06 09:16:45 +00:00
feat(rss): hot introducing rss feature as seperate utility module after docs is built
This commit is contained in:
parent
148c74c957
commit
592e22faae
@ -19,15 +19,13 @@ async function genFeed() {
|
|||||||
language: siteData.lang,
|
language: siteData.lang,
|
||||||
image: `${url}/logos/logo-308px.png`,
|
image: `${url}/logos/logo-308px.png`,
|
||||||
favicon: `${url}/favicon.ico`,
|
favicon: `${url}/favicon.ico`,
|
||||||
copyright: siteData.themeConfig.name || '-',
|
copyright: siteData.themeConfig.name || '-'
|
||||||
})
|
})
|
||||||
|
|
||||||
posts.forEach((post) => {
|
posts.forEach(post => {
|
||||||
const file = path.resolve(cwd, `dist/${post.href}`)
|
const file = path.resolve(cwd, `dist/${post.href}`)
|
||||||
const rendered = fs.readFileSync(file, 'utf-8')
|
const rendered = fs.readFileSync(file, 'utf-8')
|
||||||
const content = rendered.match(
|
const content = rendered.match(/<body>([\s\S]*)<\/body>/)
|
||||||
/<body>([\s\S]*)<\/body>/
|
|
||||||
)
|
|
||||||
|
|
||||||
feed.addItem({
|
feed.addItem({
|
||||||
title: post.title,
|
title: post.title,
|
||||||
@ -38,11 +36,9 @@ async function genFeed() {
|
|||||||
author: [
|
author: [
|
||||||
{
|
{
|
||||||
name: post.data.author,
|
name: post.data.author,
|
||||||
link: post.data.twitter
|
link: post.data.twitter ? `https://twitter.com/${post.data.twitter}` : undefined
|
||||||
? `https://twitter.com/${post.data.twitter}`
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
14
docs/.vitepress/utils/posts.data.d.ts
vendored
14
docs/.vitepress/utils/posts.data.d.ts
vendored
@ -1,10 +1,10 @@
|
|||||||
export interface PostData {
|
export interface PostData {
|
||||||
title: string,
|
title: string
|
||||||
href: string,
|
href: string
|
||||||
create: number,
|
create: number
|
||||||
update: number,
|
update: number
|
||||||
tags?: string[],
|
tags?: string[]
|
||||||
cover?: string,
|
cover?: string
|
||||||
excerpt: string,
|
excerpt: string
|
||||||
}
|
}
|
||||||
export declare const data: PostData[]
|
export declare const data: PostData[]
|
||||||
|
|||||||
@ -13,8 +13,8 @@ module.exports = {
|
|||||||
const postDir = path.join(cwd, 'docs')
|
const postDir = path.join(cwd, 'docs')
|
||||||
return fs
|
return fs
|
||||||
.readdirSync(postDir)
|
.readdirSync(postDir)
|
||||||
.filter((file) => file.endsWith('.md'))
|
.filter(file => file.endsWith('.md'))
|
||||||
.map((file) => getPost(md, file, postDir, asFeed))
|
.map(file => getPost(md, file, postDir, asFeed))
|
||||||
.sort((a, b) => b.create - a.create)
|
.sort((a, b) => b.create - a.create)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user