增加广告插件,暂时只适配Google AdSence

This commit is contained in:
stonewu 2023-08-03 20:43:21 +08:00
parent c2708006ce
commit c76548faa8
2 changed files with 87 additions and 2 deletions

View File

@ -517,7 +517,7 @@ spec:
- $formkit: group - $formkit: group
name: widgetss name: widgetss
label: 侧边栏内容 label: 侧边栏内容
help: 目前提供的小部件有profile站点资料, wechat微信, welcome小板报, steamSteam卡片, music音乐卡片, friend-link通讯录, recent-posts近期文章, comments最新评论, categories文章分类, tags文章标签, stat统计, tags-stat标签&归档&统计)。你可以随意组合或排序,以逗号隔开。 help: 目前提供的小部件有profile站点资料, wechat微信, welcome小板报, steamSteam卡片, music音乐卡片, friend-link通讯录, recent-posts近期文章, comments最新评论, categories文章分类, tags文章标签, stat统计, tags-stat标签&归档&统计), adbox广告区域。你可以随意组合或排序,以逗号隔开。
value: value:
indexWidgets: indexWidgets:
postWidgets: postWidgets:
@ -803,7 +803,69 @@ spec:
value: true value: true
- label: 隐藏 - label: 隐藏
value: false value: false
- $formkit: group
name: adbox
label: 广告区域
value:
adType:
children:
- $formkit: select
name: adType
id: adType
key: adType
label: 广告类型
value: none
options:
- label:
value: none
- label: Google AdSence
value: google
- $formkit: group
if: $get(adType).value == 'google'
name: ad_google
label: Google AdSence
help: 申请地址https://www.google.com/adsense/
value:
ad_client:
ad_slot:
ad_format:
full_width_responsive:
children:
- $formkit: text
name: ad_client
label: ad_client
help: 填写Google AdSence广告代码中的ad_client(必填)示例ca-pub-123456789
- $formkit: text
name: ad_slot
label: ad_slot
help: 填写Google AdSence单元代码中的ad_slot(必填)示例987654321
- $formkit: radio
name: ad_format
id: ad_format
key: ad_format
label: 广告尺寸
value: auto
options:
- label: 自适应
value: auto
- label: 长方形/矩形
value: rectangle
- label: 垂直
value: vertical
- label: 水平横向
value: horizontal
help: 小于 0 则展示全部分类
- $formkit: radio
name: full_width_responsive
id: full_width_responsive
key: full_width_responsive
value: false
label: 是否宽度自适应
options:
- label:
value: true
- label:
value: false
- group: footer - group: footer
label: 页脚 label: 页脚
formSchema: formSchema:

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!-- 目录 -->
<th:block th:fragment="adbox">
<div class="card-widget" th:if="${theme.config.sidebar.adbox.adType=='google'}">
<div class="item-headline"><span>广告</span></div>
<script async th:src="${'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=' + theme.config.sidebar.adbox.ad_google.ad_client}"
crossorigin="anonymous"></script>
<!-- 广告2 -->
<ins class="adsbygoogle"
style="display:block"
th:data-ad-client="${theme.config.sidebar.adbox.ad_google.ad_client}"
th:data-ad-slot="${theme.config.sidebar.adbox.ad_google.ad_slot}"
th:data-ad-format="${theme.config.sidebar.adbox.ad_google.ad_format}"
th:data-full-width-responsive="${theme.config.sidebar.adbox.ad_google.full_width_responsive}"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</th:block>
</html>