mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 23:16:46 +00:00
refactor: improve pagination logic and URL handling
Enhanced pagination logic by adjusting the condition for displaying the 'Before' link, ensuring it appears when there's more than one item, improving user navigation. Improved URL handling in Telegram post and reply processing by using regular expressions for channel replacement, enhancing compatibility and robustness.
This commit is contained in:
@@ -22,7 +22,7 @@ const afterCursor = posts[0]?.id
|
||||
|
||||
<div class="pages-container">
|
||||
{
|
||||
before && beforeCursor > 20 ? (
|
||||
before && beforeCursor > 1 ? (
|
||||
<a
|
||||
href={`${SITE_URL}before/${beforeCursor}`}
|
||||
title="Before"
|
||||
|
||||
@@ -93,7 +93,7 @@ function getReply($, item, { channel }) {
|
||||
const href = reply?.attr('href')
|
||||
if (href) {
|
||||
const url = new URL(href)
|
||||
reply?.attr('href', `${url.pathname}`.replace(channel, 'posts'))
|
||||
reply?.attr('href', `${url.pathname}`.replace(new RegExp(`/${channel}/`, 'i'), '/posts/'))
|
||||
}
|
||||
|
||||
return $.html(reply)
|
||||
@@ -130,7 +130,7 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
|
||||
? modifyHTMLContent($, $(item).find('.tgme_widget_message_text.js-message_text'), { index })
|
||||
: modifyHTMLContent($, $(item).find('.tgme_widget_message_text'), { index })
|
||||
const title = content?.text()?.match(/^.*?(?=[。::]|http\S)/g)?.[0] ?? content?.text() ?? ''
|
||||
const id = $(item).attr('data-post')?.replace(`${channel}/`, '')
|
||||
const id = $(item).attr('data-post')?.replace(new RegExp(`${channel}/`, 'i'), '')
|
||||
|
||||
const tags = $(content).find('a[href^="?q="]')?.each((_index, a) => {
|
||||
$(a)?.attr('href', `/search/${encodeURIComponent($(a)?.text())}`)
|
||||
|
||||
Reference in New Issue
Block a user