fix(route/kcna): Remove juche date parsing (#17694)
* fix(route/kcna): Remove juche date parsing * Update news.ts * Update news.ts * Update news.ts
This commit is contained in:
@@ -7,9 +7,11 @@ import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
import { art } from '@/utils/render';
|
||||
import { parseJucheDate, fixDesc, fetchPhoto, fetchVideo } from './utils';
|
||||
import { fixDesc, fetchPhoto, fetchVideo } from './utils';
|
||||
import path from 'node:path';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/:lang/:category?',
|
||||
@@ -66,12 +68,12 @@ async function handler(ctx) {
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const dateElem = item.find('.publish-time');
|
||||
const dateString = dateElem.text();
|
||||
const dateString = dateElem.text().match(/\d+\.\d+\.\d+/);
|
||||
dateElem.remove();
|
||||
return {
|
||||
title: item.text(),
|
||||
link: rootUrl + item.attr('href'),
|
||||
pubDate: parseJucheDate(dateString),
|
||||
pubDate: timezone(parseDate(dateString[0]), +9),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
@@ -87,9 +89,9 @@ async function handler(ctx) {
|
||||
item.title = $('article-main-title').text() || item.title;
|
||||
|
||||
const dateElem = $('.publish-time');
|
||||
const dateString = dateElem.text();
|
||||
const dateString = dateElem.text().match(/\d+\.\d+\.\d+/);
|
||||
dateElem.remove();
|
||||
item.pubDate = parseJucheDate(dateString) || item.pubDate;
|
||||
item.pubDate = dateString ? timezone(parseDate(dateString[0]), +9) : item.pubDate;
|
||||
|
||||
const description = fixDesc($, $('.article-content-body .content-wrapper'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user