fix(route): Kemono Posts published date (#14541)

This commit is contained in:
Ethan Shen 2024-02-24 00:14:34 +08:00 committed by GitHub
parent 774f8c98ca
commit 09eac60b2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@ const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25;
const source = ctx.params.source ?? '';
const id = ctx.params.id;
@ -40,6 +41,7 @@ module.exports = async (ctx) => {
return channelResponse.data
.filter((i) => i.content || i.attachments)
.slice(0, limit)
.map((i) => ({
title: i.content,
description: art(path.join(__dirname, 'templates', 'discord.art'), { i }),
@ -62,7 +64,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
$('.card-list__items')
.find('a')
.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit) : 25)
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
@ -90,7 +92,7 @@ module.exports = async (ctx) => {
item.author = content('.post__user-name').text();
item.title = content('.post__title span').first().text();
item.guid = item.link.replace('kemono.su', 'kemono.party');
item.pubDate = parseDate(content('.timestamp').attr('datetime'));
item.pubDate = parseDate(content('div.post__published').contents().last().text().trim());
// find the first attachment with a file extension we
// want, and set it as the enclosure