feat(route): Rewrite the API URL to original URL (#14617)

* feat(route): Rewrite the API URL to original URL

* Update notifications.js

* camelCase
This commit is contained in:
psychosispy
2024-03-03 03:07:01 +08:00
committed by GitHub
parent 94cb794993
commit 5928c5db24
+13 -7
View File
@@ -19,13 +19,19 @@ export default async (ctx) => {
});
const notifications = response.data;
const items = notifications.map((item) => ({
title: item.subject.title,
description: item.subject.title,
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
guid: item.id,
link: item.subject.url,
}));
const items = notifications.map((item) => {
let originUrl = item.subject.url ? item.subject.url.replace('https://api.github.com/repos/', 'https://github.com/') : 'https://github.com/notifications';
if (originUrl.includes('/releases/')) {
originUrl = originUrl.replace(/\/releases\/\d+$/, '/releases');
}
return {
title: item.subject.title,
description: item.subject.title,
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
guid: item.id,
link: originUrl,
};
});
ctx.set('data', {
title: 'Github Notifications',