💄 Add 51la analytics widget plug-in in sidebar.

This commit is contained in:
凡梦星尘
2022-09-12 16:43:24 +08:00
parent 20aadcf9ac
commit f3fc99ac03
10 changed files with 125 additions and 214 deletions

View File

@@ -1,176 +0,0 @@
/** User-defined style. **/
{{ $P := .Site.Params -}}
{{- with $P.sidebar -}}
{{- $width := (int (math.Max .width 240)) -}}
{{- $offset := (int (math.Max .offset 12)) -}}
{{- $padding := (int (math.Max .padding 18)) -}}
{{- $positPad := (add $width $offset) }}
.main {
{{ if eq .position "right" }}
flex-direction: row-reverse;
{{- end }}
}
.header-inner {
width: {{ $width }}px;
}
.main-inner {
width: calc(100% - {{ $positPad }}px);
}
.sidebar {
width: {{ $width }}px;
visibility: inherit;
}
.sidebar-inner {
padding: {{ $padding }}px 10px;
}
.footer-inner {
padding-{{ .position }}: {{ $positPad }}px;
}
{{- end }}
.site-author-image {
{{- if $P.avatar.rounded }}
border-radius:50%;
{{- end }}
{{- if $P.avatar.rotated }}
transition: transform 1s ease-out;
{{- end }}
}
.site-author-image:hover {
transform: rotateZ(360deg);
}
.site-state-item {
border-left: 1px solid #eee;
}
.site-state-item:first-child {
border-left: none;
}
.rss-link {
border-top: 1px dotted #ccc;
border-bottom: 1px dotted #ccc;
text-align: center;
margin: 10px 0 0 0;
}
.rss-link a {
display: block;
color: #fc6423;
border-bottom: none;
}
.rss-link a:hover {
animation-name: wobble-vertical;
animation-duration: 2s;
animation-timing-function: ease-in-out;
animation-iteration-count: 1;
}
.rss-link a:hover > i {
-webkit-transform: scaleY(-1);
transform: scaleY(-1);
}
.links-of-social a {
font-size: 0.8125em;
}
.links-of-social .fa,
.links-of-social .fab,
.links-of-social .far,
.links-of-social .fas {
margin-right: 2px;
}
.links-of-social {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.links-of-social-item {
margin: 5px 0 0;
{{- if and $P.socialIcons.enable (not $P.socialIcons.iconsOnly) }}
width: 50%;
{{- end }}
}
.links-of-social-item a {
box-sizing: border-box;
display: inline-block;
max-width: 100%;
overflow: hidden;
padding: 0 5px;
text-overflow: ellipsis;
white-space: nowrap;
}
.links-of-social-item a {
border-bottom: 0;
border-radius: 4px;
display: block;
}
.links-of-social-item a:hover {
background: var(--body-bg-color);
}
.cc-license {
{{ if eq $P.creativeCommons.size "big" }}
margin-top: 10px;
{{ else }}
margin-top: 5px;
{{- end }}
}
.back-to-top {
bottom: 30px;
}
.posts-expand .post-meta-container {
margin: 10px auto;
}
.post-meta-item-icon {
margin: 0 0 0 -5px;
}
:not(.post-meta-break) + .post-meta-item::before {
content: '|';
margin: 0 0.3em;
}
.post-meta-catg:not(:last-child)::after {
content: ';';
margin: 0px;
}
.posts-expand .post-header {
margin: 0;
}
.posts-expand .post-body {
margin: 28px 0;
}
.post-footer-btn {
text-align: center;
}
.beian img {
display: inline-block;
margin: 0 3px;
vertical-align: middle;
}
.with-love {
{{- with $P.footer.icon.color }}
color: {{ $P.footer.icon.color }};
{{- end }}
{{- if $P.footer.icon.animated }}
animation: icon-animate 1.33s ease-in-out infinite;
{{- end }}
}
/* Font Awesome */
.fa-spin {
-webkit-animation: fa-spin .8s infinite linear;
animation: fa-spin .8s infinite linear;
}

View File

@@ -65,7 +65,7 @@ $back2top_sidebar : {{ $P.backTop.sidebar }};
$avatar_rotated : {{ $P.avatar.rotated }};
$avatar_rounded : {{ $P.avatar.rounded }};
$avatar_rounded : {{ $P.avatar.rounded }};
$site_state : {{ $P.siteState }};
$site_state : {{ $P.siteState.basic }};
$social_icons_only : {{ $P.socialIcons.iconsOnly }};
$social_icons_transition : {{ $P.socialIcons.transition }};
$links_settings_layout : {{ $P.linksSets.layout }};

View File

@@ -34,15 +34,7 @@ NexT.utils = {
const wordsCount = document.getElementById('wordsCount');
if (wordsCount) {
const words = wordsCount.getAttribute('data-count');
let wordsLabel;
if (words > 10000) {
wordsLabel = (words / 10000.0).toFixed(2) + ' w';
} else if (words > 1000) {
wordsLabel = (words / 1000.0).toFixed(2) + ' k';
} else {
wordsLabel = words;
}
wordsCount.innerText = wordsLabel;
wordsCount.innerText = NexT.utils.numberFormat(words);
}
const readTimes = document.getElementById('readTimes');
@@ -72,6 +64,32 @@ NexT.utils = {
const pushDateVal = NexT.utils.diffDate(lastPushDate.getAttribute('data-lastPushDate'), 1);
lastPushDate.innerText = pushDateVal;
}
var statistic = document.querySelectorAll('#la-siteinfo-widget span');
if (statistic) {
const valIds = [0,2,4,6];
const domIds = ['today_site_pv', 'yesterday_site_pv', 'month_site_pv', 'total_site_pv']
for (var i in valIds) {
let pv = NexT.utils.numberFormat(statistic[valIds[i]].innerText);
document.getElementById(domIds[i]).innerText = pv;
}
}
},
numberFormat: function(number) {
let result;
if (number.indexOf(',') > 0) {
number = number.replaceAll(",", "");
}
if (number > 10000) {
result = (number / 10000.0).toFixed(2) + ' w';
} else if (number > 1000) {
result = (number / 1000.0).toFixed(2) + ' k';
} else {
result = number;
}
return result;
},
diffDate: function(date, mode = 0) {