fix(route/huxiu): Replace API endpoint for moment route (#20388)
This commit is contained in:
@@ -31,7 +31,7 @@ export const route: Route = {
|
||||
async function handler(ctx) {
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20;
|
||||
|
||||
const apiUrl = new URL('web-v2/moment/feed', apiMomentRootUrl).href;
|
||||
const apiUrl = new URL('web-v3/moment/feed', apiMomentRootUrl).href;
|
||||
const currentUrl = new URL('moment', rootUrl).href;
|
||||
|
||||
const { data: response } = await got.post(apiUrl, {
|
||||
@@ -40,7 +40,7 @@ async function handler(ctx) {
|
||||
},
|
||||
});
|
||||
|
||||
const items = await processItems(response.data.moment_list.datalist[0].datalist, limit, cache.tryGet);
|
||||
const items = await processItems(response.data.moment_list.datalist, limit, cache.tryGet);
|
||||
|
||||
const data = await fetchData(currentUrl);
|
||||
|
||||
|
||||
@@ -336,9 +336,9 @@ const processItems = async (items, limit, tryGet) => {
|
||||
let guid = '';
|
||||
let link = '';
|
||||
|
||||
if (item.moment_id) {
|
||||
guid = `huxiu-moment-${item.moment_id}`;
|
||||
link = item.url || new URL(`moment/${item.moment_id}.html`, rootUrl).href;
|
||||
if (item.object_type === 8) {
|
||||
guid = `huxiu-moment-${item.object_id}`;
|
||||
link = item.url || new URL(`moment/${item.object_id}.html`, rootUrl).href;
|
||||
} else if (item.brief_id || /huxiu\.com\/brief\//.test(item.url)) {
|
||||
item.brief_id = item.brief_id ?? item.aid;
|
||||
guid = `huxiu-brief-${item.brief_id}`;
|
||||
|
||||
Reference in New Issue
Block a user