Move resource follow prompts to header Telegram icon

This commit is contained in:
Codex 2026-10-31 16:30:06 +08:00
parent 2480865532
commit de6b931823
5 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace App\Services;
final class ResourceArticlePresentation
{
/** Remove legacy follow prompts only from the two daily resource columns. */
public static function body(string $html, ?string $category): string
{
if (! in_array($category, ['freenode', 'shadowrocketids'], true)) return $html;
return preg_replace_callback('~<p\b[^>]*>.*?</p>(?:\s*<p\b[^>]*>\s*</p>)*~si', static function (array $match): string {
$text = html_entity_decode(strip_tags($match[0]), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$text = preg_replace('/\s+/u', '', $text);
if (preg_match('/点击加入我们的(?:tg|telegram)频道|点击关注我们的github仓库/iu', $text)) return '';
return $match[0];
}, $html);
}
}

5
config/community.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
'telegram_url' => env('COMMUNITY_TELEGRAM_URL', 'https://t.me/clashfreenode'),
];

View File

@ -13,6 +13,7 @@ class="d-none logo-dark nc-no-lazy"
id="sidebarCollapse" aria-label="打开导航菜单" aria-controls="mobile-navigation" aria-expanded="false">
<span><i class="iconfont icon-menu"></i></span>
</button>
<div class="d-xl-none order-3 ms-auto me-2">@include('components.telegram-link')</div>
<button class="btn btn-link btn-icon btn-sm btn-rounded navbar-toggler nav-search order-3 collapsed"
data-bs-target="#navbar-search" data-bs-toggle="collapse" aria-expanded="false"
aria-controls="navbar-search">
@ -51,6 +52,7 @@ class="d-none logo-dark nc-no-lazy"
</ul>
<ul class="navbar-nav align-items-center">
<li class="nav-item me-2 me-md-3">
@include('components.telegram-link')
<a href="{{ config('path.url_github_href') }}" target="_blank" rel="noopener noreferrer">
<button class="btn btn-link btn-icon btn-sm btn-rounded nav-search collapsed">
<span>

View File

@ -0,0 +1,8 @@
<a href="{{ config('community.telegram_url') }}" target="_blank" rel="noopener noreferrer"
class="btn btn-link btn-icon btn-sm btn-rounded community-telegram"
aria-label="加入 Telegram 频道(新窗口打开)" title="Telegram 频道"
style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;padding:8px;color:#229ed9">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
<path d="M21.94 4.67 18.9 19c-.23 1.01-.83 1.26-1.67.79l-4.63-3.41-2.23 2.15c-.25.25-.46.46-.95.46l.33-4.71 8.58-7.75c.37-.33-.08-.52-.57-.19L7.15 13.02l-4.57-1.43c-.99-.31-1.01-.99.21-1.47L20.66 3.23c.83-.31 1.56.2 1.28 1.44Z"/>
</svg>
</a>

View File

@ -72,7 +72,7 @@
<img decoding="async" alt="" class="size-full wp-image-28 aligncenter" src="{{ $oArticle->sThumb }}" style="border-radius: 6px;">
</p>
@endif
{!! nl2br(\App\Services\Seo::body($oArticle->sContent)) !!}
{!! nl2br(\App\Services\Seo::body(\App\Services\ResourceArticlePresentation::body($oArticle->sContent ?? '', $oArticle->oCategory?->sSlug))) !!}
</div>