diff --git a/lib/routes/logrocket/index.ts b/lib/routes/logrocket/index.ts index 81991ab11f579f..16bb17de4b0406 100644 --- a/lib/routes/logrocket/index.ts +++ b/lib/routes/logrocket/index.ts @@ -3,10 +3,10 @@ import ofetch from '@/utils/ofetch'; // 统一使用的请求库 import { load } from 'cheerio'; // 类似 jQuery 的 API HTML 解析器 import { Route } from '@/types'; import cache from '@/utils/cache'; -import { art } from '@/utils/render'; -import { getCurrentPath } from '@/utils/helpers'; -import path from 'node:path'; -const __dirname = getCurrentPath(import.meta.url); +// import { getCurrentPath } from '@/utils/helpers'; +// import { art } from '@/utils/render'; +// import path from 'node:path'; +// const __dirname = getCurrentPath(import.meta.url); export const route: Route = { path: '/:type', categories: ['blog'], @@ -25,15 +25,15 @@ export const route: Route = { async function handler(ctx) { const type = ctx.req.param('type'); const link = 'https://blog.logrocket.com/'; - let title = '开发'; + let title = 'Dev'; if (type === 'product-management') { - title = '产品管理'; + title = 'Product Management'; } else if (type === 'ux-design') { - title = '用户体验设计'; + title = 'UX Design'; } const response = await ofetch(`${link}${type}`); const $ = load(response); - const list = $('div.post-list .post-card') + const list = $('div.post-list .post-card') .toArray() .map((item) => { item = $(item); @@ -51,11 +51,13 @@ async function handler(ctx) { cache.tryGet(item.link, async () => { const response = await ofetch(item.link); const $ = load(response); - // item.description = $('body').first().remove('#nav-bar-container').html(); - item.description = art(path.join(__dirname, 'templates/description.art'), { - header: $('#post-header').html(), - description: $('div.content-max-width').html(), - }); + // + $('div.content-max-width .sidebar-container div.code-block').remove(); + item.description = $('div.content-max-width .sidebar-container').html(); + // item.description = art(path.join(__dirname, 'templates/description.art'), { + // // header: $('#post-header').html(), + // description: $('div.content-max-width .the-content-container').remove('.lr-content div.code-block.code-block-77').remove('.lr-content .code-block.code-block-57').html(), + // }); return item; }) ) diff --git a/lib/routes/logrocket/templates/description.art b/lib/routes/logrocket/templates/description.art index bb9eae81a1ff1b..35a0134630ce03 100644 --- a/lib/routes/logrocket/templates/description.art +++ b/lib/routes/logrocket/templates/description.art @@ -1,7 +1,3 @@ -{{ if header }} - {{@ header }} -{{ /if }} - {{ if description }} {{@ description }} {{ /if }} \ No newline at end of file