From 58e6fe5b26a8cddf47d57744e3cd0485f2e1779a Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Tue, 24 Sep 2024 17:55:52 +0800 Subject: [PATCH] refactor(route): set lemmy sort param to enum and add popular category --- lib/routes/lemmy/index.ts | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/routes/lemmy/index.ts b/lib/routes/lemmy/index.ts index a8bc1fd4b642c9..7b593c4a6cf819 100644 --- a/lib/routes/lemmy/index.ts +++ b/lib/routes/lemmy/index.ts @@ -10,14 +10,41 @@ import ConfigNotFoundError from '@/errors/types/config-not-found'; export const route: Route = { path: '/:community/:sort?', - categories: ['social-media'], + categories: ['social-media', 'popular'], example: '/lemmy/technology@lemmy.world/Hot', - parameters: { community: 'Lemmmy community, for example technology@lemmy.world', sort: 'Sort by, defaut to Active' }, + parameters: { + community: 'Lemmmy community, for example technology@lemmy.world', + sort: { + description: 'Sort by', + options: [ + { value: 'Active', label: 'Active' }, + { value: 'Hot', label: 'Hot' }, + { value: 'New', label: 'New' }, + { value: 'Old', label: 'Old' }, + { value: 'TopDay', label: 'TopDay' }, + { value: 'TopWeek', label: 'TopWeek' }, + { value: 'TopMonth', label: 'TopMonth' }, + { value: 'TopYear', label: 'TopYear' }, + { value: 'TopAll', label: 'TopAll' }, + { value: 'MostComments', label: 'MostComments' }, + { value: 'NewComments', label: 'NewComments' }, + { value: 'TopHour', label: 'TopHour' }, + { value: 'TopSixHour', label: 'TopSixHour' }, + { value: 'TopTwelveHour', label: 'TopTwelveHour' }, + { value: 'TopThreeMonths', label: 'TopThreeMonths' }, + { value: 'TopSixMonths', label: 'TopSixMonths' }, + { value: 'TopNineMonths', label: 'TopNineMonths' }, + { value: 'Controversial', label: 'Controversial' }, + { value: 'Scaled', label: 'Scaled' }, + ], + default: 'Active', + }, + }, features: { requireConfig: [ { name: 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN', - description: '', + description: 'Allow user to supply unsafe domain', }, ], requirePuppeteer: false, @@ -27,7 +54,7 @@ export const route: Route = { supportScihub: false, }, name: 'Community', - maintainers: ['wb14123'], + maintainers: ['wb14123', 'pseudoyu'], handler, };