mirror of https://github.com/vtrois/kratos
feat: add OpenGraph and twitter cards (#553)
Co-authored-by: n0099 <n@n0099.net> Co-authored-by: Seaton Jiang <hi@seatonjiang.com>pull/568/head
parent
bbcae67562
commit
29366cb136
41
header.php
41
header.php
|
@ -4,22 +4,46 @@
|
||||||
* 主题页眉
|
* 主题页眉
|
||||||
* @author Seaton Jiang <hi@seatonjiang.com>
|
* @author Seaton Jiang <hi@seatonjiang.com>
|
||||||
* @license GPL-3.0 License
|
* @license GPL-3.0 License
|
||||||
* @version 2022.05.27
|
* @version 2022.12.09
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-cn">
|
<html lang="<?php bloginfo('language'); ?>">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
||||||
<title><?php wp_title('-', true, 'right'); ?></title>
|
<title><?php wp_title('-', true, 'right'); ?></title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="format-detection" content="telphone=no, email=no">
|
<meta name="format-detection" content="telphone=no,email=no">
|
||||||
<meta name="keywords" content="<?php echo keywords(); ?>">
|
|
||||||
<meta name="description" itemprop="description" content="<?php echo description(); ?>">
|
|
||||||
<meta name="theme-color" content="<?php echo kratos_option('g_chrome', '#282a2c'); ?>">
|
<meta name="theme-color" content="<?php echo kratos_option('g_chrome', '#282a2c'); ?>">
|
||||||
<meta itemprop="image" content="<?php echo share_thumbnail_url(); ?>" />
|
|
||||||
|
<meta name="keywords" itemprop="keywords" content="<?php echo keywords(); ?>">
|
||||||
|
<meta name="description" itemprop="description" content="<?php echo description(); ?>">
|
||||||
|
<?php $ogImageUrl = is_home() || !have_posts() ? kratos_option('seo_shareimg', ASSET_PATH . '/assets/img/default.jpg') : share_thumbnail_url(); ?>
|
||||||
|
<meta itemprop="image" content="<?php echo $ogImageUrl; ?>">
|
||||||
|
|
||||||
|
<meta property="og:site_name" content="<?php bloginfo('name'); ?>">
|
||||||
|
<meta property="og:url" content="<?php echo is_home() ? the_permalink() : get_site_url(); ?>">
|
||||||
|
<?php $title = is_home() ? get_the_title() : get_bloginfo('name'); ?>
|
||||||
|
<meta property="og:title" content="<?php echo $title; ?>">
|
||||||
|
<meta property="og:type" content="article">
|
||||||
|
<?php
|
||||||
|
if (!is_home()) {
|
||||||
|
$tags = get_the_tags();
|
||||||
|
if (is_array($tags)) {
|
||||||
|
foreach ($tags as $tag) { ?>
|
||||||
|
<meta property="og:article:tag" content="<?php echo $tag->name; ?>">
|
||||||
|
<?php }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<meta property="og:image" content="<?php echo $ogImageUrl; ?>">
|
||||||
|
<meta property="og:image:type" content="image/webp">
|
||||||
|
<meta property="og:locale" content="<?php bloginfo('language'); ?>">
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="<?php echo $title; ?>">
|
||||||
|
<meta name="twitter:creator" content="<?php echo the_author(); ?>">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (kratos_option('g_icon')) {
|
if (kratos_option('g_icon')) {
|
||||||
echo '<link rel="shortcut icon" href="' . kratos_option("g_icon") . '">';
|
echo '<link rel="shortcut icon" href="' . kratos_option("g_icon") . '">';
|
||||||
|
@ -33,7 +57,6 @@
|
||||||
?>
|
?>
|
||||||
</head>
|
</head>
|
||||||
<?php flush(); ?>
|
<?php flush(); ?>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="k-header">
|
<div class="k-header">
|
||||||
<nav class="k-nav navbar navbar-expand-lg navbar-light fixed-top" <?php echo kratos_option('top_img_switch', true) ? '' : 'style="background:' . kratos_option('top_color', '#24292e') . '"'; ?>>
|
<nav class="k-nav navbar navbar-expand-lg navbar-light fixed-top" <?php echo kratos_option('top_img_switch', true) ? '' : 'style="background:' . kratos_option('top_color', '#24292e') . '"'; ?>>
|
||||||
|
|
Loading…
Reference in New Issue