Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ support google adsense and AI summarize #699

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ addtoany:
- twitter


# Google Adsense
google_adsense: # <client_id>

# ---------------------------------------------------------------
# Statistics and Analytics
# See: https://theme-next.js.org/docs/third-party-services/statistics-and-analytics
Expand Down
1 change: 1 addition & 0 deletions layout/_layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}
{%- include '_partials/head/head-unique.njk' -%}
<title>{% block title %}{% endblock %}</title>
{{ partial('_third-party/adsense/index.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
{{- next_inject('head') }}
<noscript>
Expand Down
1 change: 1 addition & 0 deletions layout/_macro/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@
{######################}
{### END POST BLOCK ###}
{######################}

3 changes: 3 additions & 0 deletions layout/_third-party/adsense/google-adsense.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if theme.google_adsense %}
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client={{ theme.google_adsense }}" crossorigin="anonymous"></script>
{%- endif %}
1 change: 1 addition & 0 deletions layout/_third-party/adsense/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{%- include 'google-adsense.njk' -%}
1 change: 1 addition & 0 deletions layout/_third-party/summarize/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{%- include 'xhh-club.njk' -%}
19 changes: 19 additions & 0 deletions layout/_third-party/summarize/xhh-club.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- if theme.summarize.xhh_club %}
<script type="text/javascript">
// 可修改,摘要将显示在这个选择器选中的元素之上。
var _xhh_selector = ".post-body";
// 可修改,定制最外层 DIV 的风格。
// 默认限制宽度为 750px,上下加 8px 的镶边,4 像素圆角。
var _xhh_style = "max-width: 100%; margin:8px 0px; border-radius: 4px;";

// 以下部分不要改动
var host = '///xhh.club';
var _xhh_service_url = host + '/summarize-this/';
(function() {
var smmr = document.createElement("script");
smmr.src = host + "/static/js/summarize_this.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(smmr, s);
})();
</script>
{%- endif %}
2 changes: 2 additions & 0 deletions layout/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

{{ partial('_macro/post.njk', {post: page}) }}

{{ partial('_third-party/summarize/index.njk', {}, {cache: theme.cache.enable}) }}

{% endblock %}

{% block sidebar %}
Expand Down