码桶

发现社区成员的开源项目

飞扬 / LB_Down 公开
main
LB_Down/header.php
header.php6.5 KB
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>
        <?php
        $this->archiveTitle([
            'category' => _t('分类 %s 下的资源'),
            'search'   => _t('包含关键字 %s 的资源'),
            'tag'      => _t('标签 %s 下的资源'),
            'author'   => _t('%s 发布的资源')
        ], '', ' - ', true);
        $this->options->title();
        ?>
    </title>
    <meta name="description" content="<?php $this->options->description(); ?>">
    <link rel="icon" type="image/svg+xml" href="<?php echo lb_theme_url('assets/img/favicon.svg'); ?>">
    <script>
    // 防闪烁:渲染前应用已保存/默认的主题模式
    (function () {
        var saved = null;
        try { saved = localStorage.getItem('lb_theme'); } catch (e) {}
        var def = '<?php echo isset($this->options->themeMode) ? addslashes($this->options->themeMode) : 'light'; ?>';
        var dark = saved ? saved === 'dark'
            : (def === 'dark' || (def === 'auto' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
        if (dark) document.documentElement.setAttribute('data-theme', 'dark');
    })();
    </script>
    <link rel="stylesheet" href="<?php echo lb_theme_url('assets/css/style.css'); ?>?v=<?php echo LB_THEME_VERSION; ?>">
    <?php $this->header(); ?>
</head>
<body class="<?php echo $this->is('post') ? 'is-single' : ''; ?>">

<header class="site-header">
    <div class="container header-inner">
        <div class="site-branding">
            <a href="<?php $this->options->siteUrl(); ?>" class="site-logo" rel="home">
                <?php if ($this->options->logoUrl): ?>
                    <img src="<?php $this->options->logoUrl(); ?>" alt="<?php $this->options->title(); ?>">
                <?php else: ?>
                    <span class="site-title"><?php $this->options->title(); ?></span>
                <?php endif; ?>
            </a>
            <?php if ($this->options->siteSubtitle): ?>
                <span class="site-subtitle"><?php $this->options->siteSubtitle(); ?></span>
            <?php endif; ?>
        </div>

        <nav class="main-navigation" aria-label="主导航">
            <button class="menu-toggle" aria-expanded="false" aria-label="菜单">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                    <line x1="3" y1="12" x2="21" y2="12"/>
                    <line x1="3" y1="6" x2="21" y2="6"/>
                    <line x1="3" y1="18" x2="21" y2="18"/>
                </svg>
            </button>
            <div class="menu-overlay" id="menu-overlay"></div>
            <ul class="nav-menu">
                <li class="nav-item <?php if ($this->is('index')) echo 'current'; ?>">
                    <a href="<?php $this->options->siteUrl(); ?>">首页</a>
                </li>
                <?php
                $categories = \Widget\Metas\Category\Rows::alloc();
                while ($categories->next()):
                    $isCurrent = $this->is('category') && $this->getArchiveSlug() === $categories->slug;
                ?>
                    <li class="nav-item <?php if ($isCurrent) echo 'current'; ?>">
                        <a href="<?php $categories->permalink(); ?>"><?php $categories->name(); ?></a>
                    </li>
                <?php endwhile; ?>
            </ul>
        </nav>

        <div class="header-actions">
            <button type="button" class="theme-toggle" id="theme-toggle" aria-label="切换深浅色">
                <svg class="theme-icon theme-icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/>
                </svg>
                <svg class="theme-icon theme-icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <circle cx="12" cy="12" r="5"/>
                    <line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/>
                    <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
                    <line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/>
                    <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
                </svg>
            </button>
            <button type="button" class="search-toggle" id="search-toggle" aria-label="搜索">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                    <circle cx="11" cy="11" r="8"/>
                    <line x1="21" y1="21" x2="16.65" y2="16.65"/>
                </svg>
            </button>
        </div>
    </div>
</header>

<?php if (!$this->is('index')): ?>
<div class="breadcrumb-wrap">
    <div class="container">
        <nav class="breadcrumb" aria-label="面包屑">
            <a href="<?php $this->options->siteUrl(); ?>">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                    <path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/>
                    <polyline points="9 22 9 12 15 12 15 22"/>
                </svg>
                首页
            </a>
            <?php if ($this->is('post')): ?>
                <span class="breadcrumb-sep">›</span>
                <?php $this->category(' <span class="breadcrumb-sep">›</span> '); ?>
                <span class="breadcrumb-sep">›</span>
                <span class="breadcrumb-current"><?php $this->title(); ?></span>
            <?php elseif ($this->is('category')): ?>
                <span class="breadcrumb-sep">›</span>
                <?php $this->archiveTitle(); ?>
            <?php elseif ($this->is('search')): ?>
                <span class="breadcrumb-sep">›</span>
                <span class="breadcrumb-current">搜索: <?php $this->archiveTitle('', '', '', true); ?></span>
            <?php elseif ($this->is('page')): ?>
                <span class="breadcrumb-sep">›</span>
                <span class="breadcrumb-current"><?php $this->title(); ?></span>
            <?php endif; ?>
        </nav>
    </div>
</div>
<?php endif; ?>

<main class="site-main">
    <div class="container main-container">