Files
RSSHub/lib/routes/gov/ccdi/index.ts
T
dependabot[bot]andTony 8a0efc0ba2 chore(deps-dev): bump eslint-plugin-unicorn from 56.0.1 to 57.0.0 (#18392)
* chore(deps-dev): bump eslint-plugin-unicorn from 56.0.1 to 57.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 56.0.1 to 57.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v56.0.1...v57.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: remove unicorn plugin

* style: fix eslint issues

* style: fix more issues

* chore: flat config unicorn

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2025-02-19 05:10:11 +08:00

28 lines
795 B
TypeScript

import { Route } from '@/types';
import { getSubPath } from '@/utils/common-utils';
import { rootUrl, parseNewsList, parseArticle } from './utils';
export const route: Route = {
path: '/ccdi/*',
name: 'Unknown',
maintainers: [],
handler,
};
async function handler(ctx) {
const defaultPath = '/yaowenn/';
let pathname = getSubPath(ctx).replaceAll(/(^\/ccdi|\/$)/g, '');
pathname = pathname === '' ? defaultPath : (pathname.endsWith('/') ? pathname : pathname + '/');
const currentUrl = `${rootUrl}${pathname}`;
const { list, title } = await parseNewsList(currentUrl, '.list_news_dl2 li', ctx);
const items = await Promise.all(list.map((item) => parseArticle(item)));
return {
title,
link: currentUrl,
item: items,
};
}