feat: add snippet for xlog summary
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
20
src/modules/serverless/pack/xlog/get_summary.ts
Normal file
20
src/modules/serverless/pack/xlog/get_summary.ts
Normal 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',
|
||||
})
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user