diff --git a/page-archives.php b/page-archives.php index aaf03b3..71c39b3 100644 --- a/page-archives.php +++ b/page-archives.php @@ -15,36 +15,49 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>

-
- publishedPostsNum)->to($archives); - $year = 0; - $mon = 0; - $i = 0; - $j = 0; +
+ publishedPostsNum)->to($archives); + $year = 0; $mon = 0; $output = '
'; - while ($archives->next()) { + + while ($archives->next()) { $year_tmp = date('Y', $archives->created); $mon_tmp = date('m', $archives->created); - $y = $year; - $m = $mon; - if ($year > $year_tmp || $mon > $mon_tmp) { - $output .= ''; + + // 检查年份和月份是否变化 + if ($year != $year_tmp) { + if ($year > 0) { + $output .= '
'; // 结束上一个年份的ul和div + } + + $year = $year_tmp; $mon = 0; // 更新年份和重置月份 + $output .= '

' . date('Y', $archives->created) . '

'; // 输出新的年份 + } + + if ($mon != $mon_tmp) { + if ($mon > 0) { + $output .= ''; // 结束上一个月份的ul + } + + $mon = $mon_tmp; // 更新月份 + $output .= '

'. date('M', $archives->created) . '

'; // 确保结束最后一个月份列表和div } - $output .= '
  • -
    ' . date('m月d日', $archives->created) . '
  • '; //输出文章 - } - $output .= '
    '; - echo $output;?> - + + $output .= ''; // 结束归档div + echo $output; + ?> + need('footer.php'); ?> \ No newline at end of file