feat: add snippet for xlog summary

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2023-04-05 20:27:15 +08:00
parent f7b1d0d280
commit 710c083c4f
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
import { defineBuiltInSnippetConfig } from '../../function.types'
export default defineBuiltInSnippetConfig({
name: 'getSummary',
method: 'GET',
code: `import axios from 'axios';
export default async function handler(ctx: Context) {
const { req } = ctx
const { query } = req
const { cid, lang } = query
return axios.get('https://xlog.app/api/summary', {
params: {
cid, lang: lang || 'zh-CN'
}
}).then(data => data.data).catch(err => ({ err }))
}`,
path: 'get_summary',
reference: 'xlog',
})

View File

@@ -1,3 +1,4 @@
import get_page_id from './get_page_id'
import get_summary from './get_summary'
export const xLogPackSnippets = [get_page_id]
export const xLogPackSnippets = [get_page_id, get_summary]