Skip to content

Commit

Permalink
🦄 refactor: 统一配置命名为 snake case 风格
Browse files Browse the repository at this point in the history
  • Loading branch information
白云苍狗 committed May 31, 2024
1 parent 8263598 commit 3f69332
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/en/guide/third-party-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The default built-in Baidu, Google, Tencent three.
- `cid`:

```yaml
webAnalytics:
web_analytics:
enable: false
baidu:
google:
Expand All @@ -28,7 +28,7 @@ webAnalytics:
Take Baidu Statistics as an example:
```yaml
webAnalytics:
web_analytics:
enable: true
baidu: Baidu statistics Key
```
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/third-party-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- `cid`:

``` yaml
webAnalytics:
web_analytics:
enable: false
baidu:
google:
Expand All @@ -25,7 +25,7 @@ webAnalytics:
```
以百度统计为例:
``` yaml
webAnalytics:
web_analytics:
enable: true
baidu: 百度统计Key
```
Expand Down
2 changes: 1 addition & 1 deletion packages/hexo-theme-async/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ notice_outdate:
#### Article configuration end ###

# Page Visit Statistics
webAnalytics:
web_analytics:
enable: false
baidu: # Baidu key
google: # Tracking ID for Google statistics
Expand Down
21 changes: 11 additions & 10 deletions packages/hexo-theme-async/layout/_third-party/web-analytics.ejs
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<% if(theme.webAnalytics.enable){ %>
<% if(theme.webAnalytics.baidu){ %>
<% let webAnalytics = theme.webAnalytics || theme.web_analytics; %>
<% if(webAnalytics.enable){ %>
<% if(webAnalytics.baidu){ %>
<!-- Baidu Analytics -->
<script defer>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?<%- theme.webAnalytics.baidu %>";
hm.src = "https://hm.baidu.com/hm.js?<%- webAnalytics.baidu %>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<% } %>
<% if (theme.webAnalytics.google){ %>
<% if (webAnalytics.google){ %>
<!-- Google Analytics -->
<script async src='https://www.googletagmanager.com/gtag/js?id=<%- theme.webAnalytics.google %>'></script>
<script async src='https://www.googletagmanager.com/gtag/js?id=<%- webAnalytics.google %>'></script>
<script defer>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%= theme.webAnalytics.google %>');
gtag('config', '<%= webAnalytics.google %>');
</script>
<% } %>
<% if(theme.webAnalytics.tencent && theme.webAnalytics.tencent.sid && theme.webAnalytics.tencent.cid) { %>
<% if(webAnalytics.tencent && webAnalytics.tencent.sid && webAnalytics.tencent.cid) { %>
<!-- Tencent Analytics -->
<script defer>
let _mtac = {};
(function () {
var mta = document.createElement("script");
mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
mta.setAttribute("name", "MTAH5");
mta.setAttribute("sid", "<%= theme.webAnalytics.tencent.sid %>");
<% if(theme.webAnalytics.tencent.cid) { %>
mta.setAttribute("cid", "<%= theme.webAnalytics.tencent.cid %>");
mta.setAttribute("sid", "<%= webAnalytics.tencent.sid %>");
<% if(webAnalytics.tencent.cid) { %>
mta.setAttribute("cid", "<%= webAnalytics.tencent.cid %>");
<% } %>
let s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(mta, s);
Expand Down

0 comments on commit 3f69332

Please sign in to comment.