feat(route/thewirehindi): add routes (#19727)

* add hindi

* init

* add image in content

* remove hindi

* remove variables
This commit is contained in:
Nishant Singh 2025-08-07 22:35:31 +05:30 committed by GitHub
parent cca3733810
commit c7ab000a0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 170 additions and 0 deletions

View File

@ -0,0 +1,78 @@
import { Data, Route } from '@/types';
import got from '@/utils/got';
import { mapPostToItem } from './utils';
const categories = [
{ value: 'interview', label: 'इंटरव्यू', id: 92820 },
{ value: 'audio', label: 'ऑडियो', id: 5153 },
{ value: 'kala-sahitya', label: 'कला-साहित्य', id: 101061 },
{ value: 'campus', label: 'कैंपस', id: 5261 },
{ value: 'covid-19', label: 'कोविड-19', id: 73034 },
{ value: 'jan-ki-baat', label: 'जन की बात', id: 985 },
{ value: 'duniya', label: 'दुनिया', id: 33 },
{ value: 'north-east', label: 'नॉर्थ ईस्ट', id: 5834 },
{ value: 'prasangik', label: 'प्रासंगिक', id: 3394 },
{ value: 'bharat', label: 'भारत', id: 30 },
{ value: 'media', label: 'मीडिया', id: 3338 },
{ value: 'media-bol', label: 'मीडिया बोल', id: 7963 },
{ value: 'rajneeti', label: 'राजनीति', id: 31 },
{ value: 'vichar', label: 'विचार', id: 73061 },
{ value: 'vigyan', label: 'विज्ञान', id: 32 },
{ value: 'vishesh', label: 'विशेष', id: 2494 },
{ value: 'video', label: 'वीडियो', id: 34 },
{ value: 'samaj', label: 'समाज', id: 28 },
{ value: 'ham-bhi-bharat', label: 'हम भी भारत', id: 14383 },
{ value: 'hamare-bare-mein', label: 'हमारे बारे में', id: 29 },
];
export const route: Route = {
path: '/category/:category',
categories: ['new-media'],
example: '/thewirehindi/category/bharat',
parameters: {
category: {
description: 'Category name',
options: categories.map(({ value, label }) => ({ value, label })),
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['thewirehindi.com/category/*'],
},
],
name: 'Category',
maintainers: ['Rjnishant530'],
handler,
url: 'thewirehindi.com/',
};
async function handler(ctx) {
const { category } = ctx.req.param();
const categoryData = categories.find((cat) => cat.value === category);
if (!categoryData) {
throw new Error(`Category "${category}" not found`);
}
const apiUrl = `https://thewirehindi.com/wp-json/wp/v2/posts?categories=${categoryData.id}&_embed`;
const { data } = await got(apiUrl);
const items = data.map((v) => mapPostToItem(v));
return {
title: `The Wire Hindi - ${categoryData.label}`,
link: `https://thewirehindi.com/category/${category}/`,
item: items,
description: `Latest news from The Wire Hindi - ${categoryData.label} category`,
logo: 'https://thewirehindi.com/wp-content/uploads/2023/05/cropped-The-wire-32x32.jpeg',
language: 'hi',
} as Data;
}

View File

@ -0,0 +1,43 @@
import { Data, Route } from '@/types';
import got from '@/utils/got';
import { mapPostToItem } from './utils';
export const route: Route = {
path: '/',
categories: ['new-media'],
example: '/thewirehindi',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['thewirehindi.com/'],
},
],
name: 'Latest News',
maintainers: ['Rjnishant530'],
handler,
url: 'thewirehindi.com/',
};
async function handler() {
const apiUrl = 'https://thewirehindi.com/wp-json/wp/v2/posts?_embed';
const { data } = await got(apiUrl);
const items = data.map((v) => mapPostToItem(v));
return {
title: 'The Wire Hindi - Latest News',
link: 'https://thewirehindi.com/',
item: items,
description: 'Latest news from The Wire Hindi',
logo: 'https://thewirehindi.com/wp-content/uploads/2023/05/cropped-The-wire-32x32.jpeg',
language: 'hi',
} as Data;
}

View File

@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'The Wire Hindi',
url: 'thewirehindi.com',
lang: 'hi',
};

View File

@ -0,0 +1,9 @@
{{@ excerpt }}
<br><br>
{{ if image }}
<img src="{{ image }}" alt="{{ altText }}" style="max-width: 100%; height: auto;">
<br><br>
{{ /if }}
{{ if content }}
{{@ content }}
{{ /if }}

View File

@ -0,0 +1,33 @@
import { DataItem } from '@/types';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import path from 'node:path';
export function mapPostToItem(post): DataItem {
const featuredMedia = post._embedded?.['wp:featuredmedia']?.find((v) => v.id === post.featured_media);
const image = featuredMedia?.source_url;
const altText = featuredMedia?.alt_text || featuredMedia?.title?.rendered || 'Featured Image';
return {
title: post.title.rendered,
description: art(path.join(__dirname, 'templates/description.art'), {
excerpt: post.excerpt.rendered,
content: post.content.rendered,
image,
altText,
}),
link: post.link,
pubDate: parseDate(post.date_gmt),
updated: parseDate(post.modified_gmt),
itunes_item_image: image,
image,
author:
post._embedded?.author
?.map((v) => ({
name: v.name,
url: v.link,
avatar: v.avatar_urls?.['96'] || v.avatar_urls?.['48'] || v.avatar_urls?.['24'],
}))
.join(', ') || 'The Wire Hindi',
category: post._embedded?.['wp:term']?.flat().map((v) => v.name),
} as DataItem;
}