Merge pull request #363 from Stonewuu/main

增加广告模块,暂时只适配Google AdSence
This commit is contained in:
liuzhihang 2023-08-04 23:45:32 +08:00 committed by GitHub
commit 51ba06639f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 86 additions and 2 deletions

View File

@ -517,7 +517,7 @@ spec:
- $formkit: group
name: widgetss
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:
indexWidgets:
postWidgets:
@ -803,7 +803,68 @@ spec:
value: true
- label: 隐藏
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
- $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
label: 页脚
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>