From d7cf77544ca65b9243d4c3f79fdf39e0104f5eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=AE=87?= <448766534@qq.com> Date: Fri, 6 Dec 2019 12:56:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Google=20Analytics=EF=BC=8C=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++ _config.yml | 5 +++ layout/_partial/baidu-analytics.ejs | 11 ++++++ layout/_partial/google-analytics.ejs | 14 ++++++++ layout/_partial/head.ejs | 53 ++++++++++++++-------------- 5 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 layout/_partial/baidu-analytics.ejs create mode 100644 layout/_partial/google-analytics.ejs diff --git a/README.md b/README.md index 817eccc..5d1f197 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,11 @@ cnzz: enable: true url: # +# Google Analytics +google_analytics: '' +# 百度统计 +baidu_analytics: '' + # 数学公式 mathjax: true diff --git a/_config.yml b/_config.yml index a264009..c77e3d5 100644 --- a/_config.yml +++ b/_config.yml @@ -86,6 +86,11 @@ cnzz: enable: true url: https://s9.cnzz.com/z_stat.php?id=1278069914&web_id=1278069914 +# Google Analytics +google_analytics: '' +# 百度统计 +baidu_analytics: '' + # 数学公式 mathjax: true diff --git a/layout/_partial/baidu-analytics.ejs b/layout/_partial/baidu-analytics.ejs new file mode 100644 index 0000000..e9bd0b6 --- /dev/null +++ b/layout/_partial/baidu-analytics.ejs @@ -0,0 +1,11 @@ +<% if (theme.baidu_analytics){ %> + +<% } %> diff --git a/layout/_partial/google-analytics.ejs b/layout/_partial/google-analytics.ejs new file mode 100644 index 0000000..f3025dc --- /dev/null +++ b/layout/_partial/google-analytics.ejs @@ -0,0 +1,14 @@ +<% if (theme.google_analytics){ %> +<%# "Google Analytics" %> + +<%# "End Google Analytics" %> +<% } %> diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index 69bc754..dbe140a 100644 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -1,34 +1,33 @@ - - - <% var title = page.title; if (is_archive()) { title = __('archive_a'); if + + + + <% var title = page.title; if (is_archive()) { title = __('archive_a'); if (is_month()) { title += ': ' + page.year + '/' + page.month; } else if (is_year()) { title += ': ' + page.year; } } else if (is_category()) { title = __('categories.ejs') + ': ' + page.categories; } else if (is_tag()) { title = __('tag') + ': ' + page.tag; } %> <% if (page.keywords){ %> - - <% } else if (config.keywords){ %> - - <% } %> <% if (page.description){ %> - - <% } else if (config.description){ %> - - <% } %> - - - <% if (title){ %><%= title %> | <% } %> <%= config.title %> - - <% if (theme.favicon){ %> - - <% } %> - <%- css('css/style') %> <% if (theme.fancybox){ %> <%- + + <% } else if (config.keywords){ %> + + <% } %> <% if (page.description){ %> + + <% } else if (config.description){ %> + + <% } %> + + + <% if (title){ %><%= title %> | <% } %> <%= config.title %> + + <% if (theme.favicon){ %> + + <% } %> + <%- css('css/style') %> <% if (theme.fancybox){ %> <%- css('fancybox/jquery.fancybox.min') %> <% } %> <%- js('/js/pace.min.js') %> - - + + <%- partial('google-analytics') %> + <%- partial('baidu-analytics') %> + + + \ No newline at end of file