-
Notifications
You must be signed in to change notification settings - Fork 4
/
header.php
189 lines (186 loc) · 11.8 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta property="og:site_name" content="<?php $this->options->title(); ?>"/>
<?php
$mateImage = ($this->options->faviconUrl) ? $this->options->faviconUrl : (($this->options->logoUrl) ? $this->options->logoUrl : $this->options->themeUrl."assets/images/logo.png");
?>
<?php if ($this->is("index")): ?>
<meta property="og:type" content="blog"/>
<meta property="og:url" content="<?php $this->options->siteUrl(); ?>"/>
<meta property="og:title" content="<?php $this->options->title(); ?>"/>
<meta property="og:author" content="<?php $this->author->name(); ?>"/>
<meta property="og:description" content="<?php $this->options->description(); ?>"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="<?php $this->options->title(); ?>">
<meta name="twitter:title" content="<?php $this->options->title(); ?>">
<meta name="twitter:description" content="<?php $this->options->description(); ?>">
<meta property="og:image" content="<?php echo $mateImage; ?>"/>
<meta name="twitter:image" content="<?php echo $mateImage; ?>">
<meta name="keywords" content="<?php $this->keywords(); ?>">
<meta name="description" content="<?php $this->options->description(); ?>">
<?php endif; ?>
<?php if ($this->is("post") || $this->is("page") || $this->is("attachment")): ?>
<meta property="og:type" content="article"/>
<meta property="og:url" content="<?php $this->permalink(); ?>"/>
<meta property="og:title" content="<?php $this->title(); ?>"/>
<meta property="og:author" content="<?php $this->author(); ?>"/>
<meta property="og:description" content="<?php
$d = $this->fields->description;
if (empty($d) || !$this->is("single")) {
if ($this->getDescription()) {
echo $this->getDescription();
}
} else {
echo $d;
}
?>"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="<?php $this->options->title(); ?>">
<meta name="twitter:title" content="<?php $this->title(); ?>">
<meta name="twitter:description" content="<?php
$d = $this->fields->description;
if (empty($d) || !$this->is("single")) {
if ($this->getDescription()) {
echo $this->getDescription();
}
} else {
echo $d;
}
?>">
<?php
if ($this->is("post") || $this->is("page")) {
$mateImage = xaGetThumbnail($this->cid, $mateImage);
}
?>
<meta property="og:image" content="<?php echo $mateImage; ?>"/>
<meta name="twitter:image" content="<?php echo $mateImage; ?>">
<meta property="article:published_time" content="<?php $this->date("c"); ?>"/>
<meta property="article:published_first" content="<?php $this->options->title(); ?>, <?php $this->permalink(); ?>"/>
<meta name="keywords" content="<?php
$k = $this->fields->keyword;
if (empty($k)) {
echo $this->keywords();
} else {
echo $k;
}
?>">
<meta name="description" content="<?php
$d = $this->fields->description;
if (empty($d) || !$this->is("single")) {
if ($this->getDescription()) {
echo $this->getDescription();
}
} else {
echo $d;
}
?>"/>
<?php endif; ?>
<title><?php
$this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ' - '); ?><?php $this->options->title(); ?><?php if($this->_currentPage>1) echo ' - 第 '.$this->_currentPage.' 页 '; ?></title>
<?php if ($this->options->faviconUrl): ?>
<link rel="shoucut icon" href="<?php $this->options->faviconUrl(); ?>">
<?php endif; ?>
<!-- <link rel="preload" href="--><?php //$this->options->themeUrl("assets/css/fonts/tabler-icons.woff2") ?><!--" as="font" type="font/woff2" crossorigin />-->
<link href="<?php $this->options->themeUrl("assets/css/tailwind.min.css?v=" . xaGetVersion()); ?>" rel="stylesheet" />
<link href="<?php $this->options->themeUrl("assets/css/tabler-icons.min.css"); ?>" rel="stylesheet"/>
<link href="<?php $this->options->themeUrl("assets/js/OwO/OwO.min.css?v=" . xaGetVersion()); ?>" rel="stylesheet" />
<link href="<?php $this->options->themeUrl("assets/css/outline.min.css?v=" . xaGetVersion()); ?>" rel="stylesheet" />
<link href="<?php $this->options->themeUrl("assets/css/xa-ink.css?v=" . xaGetVersion()); ?>" rel="stylesheet" />
<link href="<?php $this->options->themeUrl("assets/css/xa-ink-post.css?v=" . xaGetVersion()); ?>" rel="stylesheet" />
<?php $this->header("description=&generator=&pingback=&template=&xmlrpc=&wlw=&commentReply=&keywords="); ?>
<script type="text/javascript" src="<?php $this->options->themeUrl("assets/js/jquery.min.js?v=" . xaGetVersion()); ?>"></script>
<script type="text/javascript" src="<?php $this->options->themeUrl("assets/js/jquery.lazyload.min.js?v=" . xaGetVersion()); ?>"></script>
<script type="text/javascript" src="<?php $this->options->themeUrl("assets/js/jquery.sticky-sidebar.min.js?v=" . xaGetVersion()); ?>"></script>
<script type="text/javascript" src="<?php $this->options->themeUrl("assets/js/OwO/OwO.min.js?v=" . xaGetVersion()); ?>"></script>
<script type="text/javascript">
var siteUrl = '<?php $this->options->siteUrl() ?>';
</script>
<script type="text/javascript" src="<?php $this->options->themeUrl("assets/js/xa-ink.js?v=" . xaGetVersion()); ?>"></script>
<?php if($this->options->headerStatJs): ?>
<script type="text/javascript">
<?php $this->options->headerStatJs(); ?>
</script>
<?php endif ?>
</head>
<body>
<!-- 头部导航栏 -->
<header id="header" class="fixed top-0 z-30 w-full flex items-center shadow-md border-b-3 border-gray-100">
<div class="relative flex items-center w-full">
<div class="xa-header mx-auto flex items-center justify-between h-full w-full">
<div class="xa-logo flex items-center justify-center">
<?php if ($this->options->logoUrl): ?>
<a href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->logoUrl() ?>" alt="<?php $this->options->title() ?>" class="w-full">
</a>
<?php else: ?>
<a href="<?php $this->options->siteUrl(); ?>">
<img src="<?php $this->options->themeUrl("assets/images/logo.png"); ?>" alt="<?php $this->options->title() ?>" class="w-full">
</a>
<?php endif; ?>
</div>
<!-- 搜索框 -->
<div class="flex-1 hidden lg:block flex items-center justify-start">
<form method="post" action="<?php $this->options->siteUrl(); ?>" class="xa-search flex items-center w-full dark:bg-gray-700">
<input type="text" name="s" placeholder="搜索一下,你就找到"
class="w-full border-l-2 border-t-2 border-b-2 border-gray-200 dark:border-gray-600 rounded-l-lg py-2 px-4 h-10 focus:outline-none focus:border-blue-500"
value="<?php if($this->is('search')) echo $this->keywords; ?>" />
<button type="submit" class="bg-blue-500 text-white px-4 py-2 h-10 outline-blue-500 rounded-r-lg hover:bg-blue-600 focus:outline-none">搜索一下</button>
</form>
</div>
<div class="hidden lg:block lg:mr-32" style="width: 340px;"></div>
</div>
<!-- 右侧靠右边栏 -->
<div class="absolute right-2">
<!-- 菜单和主题切换按钮 -->
<div class="flex items-center space-x-2">
<!-- Page -->
<nav class="xa-nav hidden lg:block flex items-center justify-between space-x-4 mr-2">
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while($pages->next()): ?>
<a<?php if($this->is('page', $pages->slug)): ?> class="xa-selected"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>
</nav>
<?php if($this->user->hasLogin()): ?>
<!-- 登录后用户信息 -->
<div class="relative">
<div class="xa-login flex items-center">
<!-- 用户头像 -->
<img src="<?php echo xaGetAvatar($this->user->mail); ?>" class="w-9 h-9 rounded-full mr-2">
<!-- 用户名 -->
<div><?php $this->user->screenName() ?></div>
<!-- 图标 -->
<div class="i"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-down"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 9l6 6l6 -6" /></svg></div>
</div>
<!-- 下拉框 -->
<div class="xa-login-menu xa-theme absolute top-full left-1 w-28 bg-white rounded-md shadow-md z-10 hidden">
<!-- 进入后台 -->
<div class="block px-4 py-2"><a href="<?php $this->options->adminUrl(); ?>" class="rounded-full px-3 py-1">进入后台</a></div>
<!-- 退出菜单 -->
<div class="block px-4 py-2"><a href="<?php $this->options->logoutUrl(); ?>" class="rounded-full px-3 py-1">退出</a></div>
</div>
</div>
<?php else: ?>
<!-- 登录button -->
<a href="<?php $this->options->adminUrl('login.php'); ?>" class="xa-button px-3 py-0.5 bg-blue-500 text-white rounded-md hover:bg-blue-600 focus:outline-none">登录</a>
<?php endif; ?>
<!-- 主题 -->
<button id="themeToggle" class="dark:bg-gray-600 px-2 py-1.5 rounded-md hover:focus:outline-none" title="切换主题">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-moon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" /></svg>
</button>
<!-- 移动端菜单 -->
<button id="mobileNavToggle" class="lg:hidden px-2 py-1.5 rounded-md hover:focus:outline-none" title="菜单"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-menu-2"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 6l16 0" /><path d="M4 12l16 0" /><path d="M4 18l16 0" /></svg></button>
</div>
</div>
</div>
</header>