归档页面代码记录如下:

<?php
/**
 * 归档
 *
 * @package custom
 */
?>
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div id="main">
<article class="post-content">
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
    $year=0; $mon=0; $i=0; $j=0;
    $output = '<div id="archives">';
    while($archives->next()):
        $year_tmp = date('Y',$archives->created);
        $mon_tmp = date('m',$archives->created);
        $y=$year; $m=$mon;
        if ($mon != $mon_tmp && $mon > 0) $output .= '</ul></li>';
        if ($year != $year_tmp && $year > 0) $output .= '</ul>';
        if ($year != $year_tmp) {
            $year = $year_tmp;
            $output .= '<h4 class="al-title al_mon">'. $year .' 年</h4><ul class="al_post_list">'; 
        }
        if ($mon != $mon_tmp) {
            $mon = $mon_tmp;
            $output .= '<li><span class="al_mon">'. $year .' 年'. $mon .' 月</span><ul class="a_post_list">';
        }
        $output .= '<li><a href="'.$archives->permalink .'">'. $archives->title .'</a><div class="r">'.date('m/d',$archives->created).'</div></li>';
    endwhile;
    $output .= '</ul></li></ul></div>';
    echo $output;
?>
</article>
</div>
<?php $this->need('footer.php'); ?>

jQuery 代码记录如下:

jQuery(document).ready(function($) {
(function ($) {
$(function() {
  var $a = $('#archives'),
  $m = $('.al_mon', $a),
  $l = $('.al_post_list', $a),
  $l_f = $('.al_post_list:first', $a);
  $l.hide();$l_f.show();
  $r = $('.a_post_list', $a),
  $r_f = $('.a_post_list:first', $a);
  $r.hide();$r_f.show();
  $m.css('cursor', 'pointer').on('click', function(){
    $(this).next().slideToggle(400);
  });
});
})(jQuery);
});