Skip to content

Commit

Permalink
fix(route): Kemono Posts published date (DIYgod#14541)
Browse files Browse the repository at this point in the history
  • Loading branch information
nczitzk authored Feb 23, 2024
1 parent 774f8c9 commit 09eac60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/v2/kemono/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 }),
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 09eac60

Please sign in to comment.