Files
argon-theme/template-parts/content-preview-2.php
nanhaoluo 135c2269c7 fix: 修复 Mermaid 渲染问题
- 启用代码块转换功能(移除 convertMermaidCodeblocks 中的 return 语句)
- 添加完整的 Mermaid 代码块检测选择器
- 修复首页预览中显示原始 Mermaid 代码的问题
- 添加 argon_remove_mermaid_from_preview 函数过滤预览内容
- 更新三个文章预览模板,在预览中用 [Mermaid 图表] 替代原始代码
2026-01-27 00:28:25 +08:00

158 lines
3.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<article class="post card bg-white shadow-sm border-0 <?php if (get_option('argon_enable_into_article_animation') == 'true'){echo 'post-preview';} ?> post-preview-layout-2" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="post-header <?php if (argon_has_post_thumbnail()){echo " post-header-with-thumbnail";}?>">
<?php
if (argon_has_post_thumbnail()){
echo argon_get_post_thumbnail_html(0, 'post-thumbnail', 'thumbnail');
}
?>
</header>
<div class="post-content-container">
<a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
$trim_words_count = get_option('argon_trim_words_count', 175);
?>
<?php if ($trim_words_count > 0){ ?>
<div class="post-content">
<?php
$content_for_preview = get_the_content('...');
// 移除 Mermaid shortcode避免在预览中显示原始代码
$content_for_preview = argon_remove_mermaid_from_preview($content_for_preview);
if (get_option("argon_hide_shortcode_in_preview") == 'true'){
$preview = wp_trim_words(do_shortcode($content_for_preview), $trim_words_count);
}else{
$preview = wp_trim_words($content_for_preview, $trim_words_count);
}
if (post_password_required()){
$preview = __("这篇文章受密码保护,输入密码才能阅读", 'argon');
}
if ($preview == ""){
$preview = __("这篇文章没有摘要", 'argon');
}
if ($post -> post_excerpt){
$preview = $post -> post_excerpt;
}
// 应用特殊样式处理(黑幕、彩幕等)
if (function_exists('argon_apply_comment_macros')) {
$preview = argon_apply_comment_macros($preview);
}
echo $preview;
?>
</div>
<?php
}
?>
<div class="post-meta">
<?php
$metaList = explode('|', get_option('argon_article_meta', 'time|views|comments|categories'));
if (is_sticky() && is_home() && ! is_paged()){
array_unshift($metaList, "sticky");
}
if (post_password_required()){
array_unshift($metaList, "needpassword");
}
for ($i = 0; $i < count($metaList); $i++){
if ($i > 0){
echo ' <div class="post-meta-devide">|</div> ';
}
echo get_article_meta($metaList[$i]);
}
?>
<?php
global $post;
$post_content_full = apply_filters('the_content', preg_replace( '<!--more(.*?)-->', '', $post -> post_content));
$post_content_with_more = apply_filters('the_content', $post -> post_content);
?>
<?php if (!post_password_required() && get_option("argon_show_readingtime") != "false" && is_readingtime_meta_hidden() == False) {
echo get_article_reading_time_meta($post_content_full);
} ?>
</div>
<?php if (has_tag()) { ?>
<div class="post-tags">
<i class="fa fa-tags" aria-hidden="true"></i>
<?php
$tags = get_the_tags();
foreach ($tags as $tag) {
echo "<a href='" . get_category_link($tag -> term_id) . "' target='_blank' class='tag badge badge-secondary post-meta-detail-tag'>" . $tag -> name . "</a>";
}
?>
</div>
<?php } ?>
</div>
</article>