feat: enhance header rendering and description extraction

- Optimized header component to directly set HTML content for improved rendering performance and security.
- Modified description extraction method to retrieve HTML content, enhancing the accuracy and richness of displayed information.
- Added word-break property to site intro for better handling of long words and URLs.
This commit is contained in:
ccbikai
2024-08-06 09:30:07 +08:00
parent cdedeb8924
commit 5c998c6c34
2 changed files with 3 additions and 4 deletions

View File

@@ -115,15 +115,14 @@ const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
{
channel?.description && channel?.description.length > 0 && (
<div class="text-box" id="site-intro">
{channel?.description}
</div>
<div class="text-box" id="site-intro" set:html={channel?.description} />
)
}
<style>
#site-intro {
color: var(--secondary-color);
word-break: break-word;
}
.social-icon {

View File

@@ -149,7 +149,7 @@ export async function getChannelInfo(Astro, { before = '', after = '', q = '', t
const channelInfo = {
posts,
title: $('.tgme_channel_info_header_title')?.text(),
description: $('.tgme_channel_info_description')?.text(),
description: $('.tgme_channel_info_description')?.html(),
avatar: $('.tgme_page_photo_image img')?.attr('src'),
}