Files
blog/usr/themes/default/functions.php
2026-03-21 17:04:18 +08:00

78 lines
2.7 KiB
PHP
Executable File

<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
function themeConfig($form)
{
$logoUrl = new \Typecho\Widget\Helper\Form\Element\Text(
'logoUrl',
null,
null,
_t('站点 LOGO 地址'),
_t('在这里填入一个图片 URL 地址, 以在网站标题前加上一个 LOGO')
);
$form->addInput($logoUrl->addRule('url', _t('请填写一个合法的URL地址')));
$sidebarBlock = new \Typecho\Widget\Helper\Form\Element\Checkbox(
'sidebarBlock',
[
'ShowRecentPosts' => _t('显示最新文章'),
'ShowRecentComments' => _t('显示最近回复'),
'ShowCategory' => _t('显示分类'),
'ShowArchive' => _t('显示归档'),
'ShowOther' => _t('显示其它杂项')
],
['ShowRecentPosts', 'ShowRecentComments', 'ShowCategory', 'ShowArchive', 'ShowOther'],
_t('侧边栏显示')
);
$form->addInput($sidebarBlock->multiMode());
}
function postMeta(
\Widget\Archive $archive,
string $metaType = 'archive'
)
{
$titleTag = $metaType == 'archive' ? 'h2' : 'h1';
?>
<<?php echo $titleTag ?> class="post-title" itemprop="name headline">
<a itemprop="url"
href="<?php $archive->permalink() ?>"><?php $archive->title() ?></a>
</<?php echo $titleTag ?>>
<?php if ($metaType != 'page'): ?>
<ul class="post-meta">
<li itemprop="author" itemscope itemtype="http://schema.org/Person">
<?php _e('作者'); ?>: <a itemprop="name"
href="<?php $archive->author->permalink(); ?>"
rel="author"><?php $archive->author(); ?></a>
</li>
<li><?php _e('时间'); ?>:
<time datetime="<?php $archive->date('c'); ?>" itemprop="datePublished"><?php $archive->date(); ?></time>
</li>
<li><?php _e('分类'); ?>: <?php $archive->category(','); ?></li>
<?php if ($metaType == 'archive'): ?>
<li itemprop="interactionCount">
<a itemprop="discussionUrl"
href="<?php $archive->permalink() ?>#comments"><?php $archive->commentsNum(_t('暂无评论'), _t('1 条评论'), _t('%d 条评论')); ?></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<?php
}
/*
function themeFields($layout)
{
$logoUrl = new \Typecho\Widget\Helper\Form\Element\Text(
'logoUrl',
null,
null,
_t('站点LOGO地址'),
_t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO')
);
$layout->addItem($logoUrl);
}
*/