From 0ba52293a25274267359148a1b23c523fad9032f Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 20 Mar 2020 18:28:13 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20feat:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=8B=E5=8B=95=E5=BB=A3=E5=91=8A=E4=BD=8D=E7=BD=AE=20:spark?= =?UTF-8?q?les:=20feat:=20aside=20info=20=E8=A3=8F=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9C=AC=E7=AB=99=E7=B8=BD=E6=96=87=E5=AD=97=20:art:=20refacto?= =?UTF-8?q?r:=20post-meta=E4=BB=A3=E7=A2=BC=E7=B5=90=E6=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 17 +++-- languages/default.yml | 1 + languages/en.yml | 1 + languages/zh-CN.yml | 1 + languages/zh-TW.yml | 1 + layout/includes/header/post-info.pug | 92 ++++++++++++++----------- layout/includes/mixins/UI.pug | 5 ++ layout/includes/recent-posts.pug | 6 +- layout/includes/widget/card_ad.pug | 2 + layout/includes/widget/card_webinfo.pug | 4 ++ layout/includes/widget/index.pug | 2 + layout/post.pug | 8 ++- source/css/_global/index.styl | 7 ++ source/css/_layout/head.styl | 20 +++--- 14 files changed, 111 insertions(+), 56 deletions(-) create mode 100644 layout/includes/widget/card_ad.pug diff --git a/_config.yml b/_config.yml index a60630f..27c7668 100644 --- a/_config.yml +++ b/_config.yml @@ -70,7 +70,7 @@ algolia_search: hits_stats: "${hits} results found in ${time} ms" # Local search -# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#本地搜索 +# Please see doc for more details: https://docs.jerryc.me/config.html#本地搜索 # --------------- local_search: enable: false @@ -79,7 +79,7 @@ local_search: hits_empty: "We didn't find any results for the search: ${query}" # if there are no result # MathJax -# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#MathJax +# Please see doc for more details: https://docs.jerryc.me/config.html#mathjax # --------------- mathjax: enable: false @@ -168,9 +168,11 @@ post_meta: categories: true # true or false 文章頁是否顯示分類 tags: true # true or false 文章頁是否顯示標籤 -# Please see doc for more details: https://jerryc.me/posts/21cfbf15/#字數統計 +# Please see doc for more details: https://docs.jerryc.me/config.html#字數統計 wordcount: - enable: false + post_wordcount: true + min2read: true + total_wordcount: true toc: enable: true @@ -313,6 +315,13 @@ google_adsense: client: enable_page_level_ads: true +# 廣告插入位置 +# 適用於開啓手動廣告的配置 +# ad: +# index: +# aside: +# post: + #### 站長驗證 #### # Google Webmaster tools verification setting # See: https://www.google.com/webmasters/ diff --git a/languages/default.yml b/languages/default.yml index 29894f9..441e6d5 100644 --- a/languages/default.yml +++ b/languages/default.yml @@ -66,6 +66,7 @@ aside: headline: Info article_name: Article runtime_name: Run time + site_wordcount: Total Count site_uv_name: UV site_pv_name: PV diff --git a/languages/en.yml b/languages/en.yml index 29894f9..441e6d5 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -66,6 +66,7 @@ aside: headline: Info article_name: Article runtime_name: Run time + site_wordcount: Total Count site_uv_name: UV site_pv_name: PV diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 9b4e224..a78d07e 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -68,6 +68,7 @@ aside: headline: 网站资讯 article_name: 文章数目 runtime_name: 已运行时间 + site_wordcount: 本站总字数 site_uv_name: 本站访客数 site_pv_name: 本站总访问量 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 8aad902..166be03 100644 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -68,6 +68,7 @@ aside: headline: 網站資訊 article_name: 文章數目 runtime_name: 已運行時間 + site_wordcount: 本站總字數 site_uv_name: 本站訪客數 site_pv_name: 本站總訪問量 diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug index fd533d8..1737790 100644 --- a/layout/includes/header/post-info.pug +++ b/layout/includes/header/post-info.pug @@ -1,51 +1,63 @@ #post-info #post-title .posttitle= page.title || _p('no_title') + #post-meta - if (theme.post_meta.post.date_type) - if (theme.post_meta.post.date_type === 'both') - time.post-meta__date - i.fa.fa-calendar(aria-hidden="true") - =' '+_p('post.created')+' '+date(page.date, config.date_format) - span.post-meta__separator | - i.fa.fa-history(aria-hidden="true") - =' '+_p('post.updated')+' '+date(page.updated, config.date_format) - else - - var data_type_update = theme.post_meta.post.date_type === 'updated' - - var date_type = data_type_update ? 'updated' : 'date' - - var date_icon = data_type_update ? 'fa-history' :'fa-calendar' - - var data_info = data_type_update ? _p('post.updated') : _p('post.created') - time.post-meta__date - i.fa(class=date_icon aria-hidden="true") - =' ' + data_info + ' ' + date(page[date_type], config.date_format) - - if (theme.post_meta.post.categories && page.categories.data.length > 0) + .meta-firstline if (theme.post_meta.post.date_type) - span.post-meta__separator | - span - each item, index in page.categories.data - i.fa.fa-inbox.post-meta__icon(aria-hidden="true") - a(href=url_for(item.path)).post-meta__categories #[=item.name] - if (index < page.categories.data.length - 1) - i.fa.fa-angle-right.post-meta__separator(aria-hidden="true") - .post-meta-wordcount - if (theme.wordcount && theme.wordcount.enable) - - var wordCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-file-word' : 'fa fa-file-word-o' - i.post-meta__icon(class=wordCountIcon aria-hidden="true") - span= _p('post.wordcount') + ':' - span.word-count= wordcount(page.content) - span.post-meta__separator | - - var readCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-clock' : 'fa fa-clock-o' - i.post-meta__icon(class=readCountIcon aria-hidden="true") - span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160})) - .post-meta-pv-cv - if (theme.wordcount && theme.wordcount.enable && theme.busuanzi.page_pv) + if (theme.post_meta.post.date_type === 'both') + time.post-meta__date + i.fa.fa-calendar(aria-hidden="true") + =' '+_p('post.created')+' '+date(page.date, config.date_format) + span.post-meta__separator | + i.fa.fa-history(aria-hidden="true") + =' '+_p('post.updated')+' '+date(page.updated, config.date_format) + else + - var data_type_update = theme.post_meta.post.date_type === 'updated' + - var date_type = data_type_update ? 'updated' : 'date' + - var date_icon = data_type_update ? 'fa-history' :'fa-calendar' + - var data_info = data_type_update ? _p('post.updated') : _p('post.created') + time.post-meta__date + i.fa(class=date_icon aria-hidden="true") + =' ' + data_info + ' ' + date(page[date_type], config.date_format) + + if (theme.post_meta.post.categories && page.categories.data.length > 0) + span.post-meta__categories + if (theme.post_meta.post.date_type) + span.post-meta__separator | + + each item, index in page.categories.data + i.fa.fa-inbox.post-meta__icon(aria-hidden="true") + a(href=url_for(item.path)).post-meta__categories #[=item.name] + if (index < page.categories.data.length - 1) + i.fa.fa-angle-right.post-meta__separator(aria-hidden="true") + + .meta-secondline + - let postWordcount = theme.wordcount.post_wordcount || theme.wordcount.min2read + if (postWordcount) + span.post-meta-wordcount + if theme.wordcount.post_wordcount + - var wordCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-file-word' : 'fa fa-file-word-o' + i.post-meta__icon(class=wordCountIcon aria-hidden="true") + span= _p('post.wordcount') + ':' + span.word-count= wordcount(page.content) + if theme.wordcount.min2read + span.post-meta__separator | + if theme.wordcount.min2read + - var readCountIcon = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-clock' : 'fa fa-clock-o' + i.post-meta__icon(class=readCountIcon aria-hidden="true") + span= _p('post.min2read', min2read(page.content, {cn: 350, en: 160})) + + .meta-thirdline + span.post-meta-pv-cv + if (postWordcount && theme.busuanzi.page_pv) span.post-meta__separator | if theme.busuanzi.page_pv i.fa.fa-eye.post-meta__icon(aria-hidden="true") span=_p('post.page_pv') + ':' span#busuanzi_value_page_pv - + + span.post-meta-commentcount - var commentCount = theme.fontawesome_v5 && theme.fontawesome_v5.enable ? 'far fa-comments' : 'fa fa-comment-o' if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false)) if (theme.busuanzi && theme.busuanzi.page_pv) @@ -54,14 +66,14 @@ span= _p('post.comments') + ':' span.disqus-comment-count.comment-count a(href=full_url_for(page.path) + '#disqus_thread') - if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) + else if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false) if (theme.busuanzi && theme.busuanzi.page_pv) span.post-meta__separator | i.post-meta__icon(class=commentCount aria-hidden="true") span= _p('post.comments') + ':' a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl") span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount") - if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) + else if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false) if (theme.busuanzi && theme.busuanzi.page_pv) span.post-meta__separator | i.post-meta__icon(class=commentCount aria-hidden="true") diff --git a/layout/includes/mixins/UI.pug b/layout/includes/mixins/UI.pug index be072ec..b0e5001 100644 --- a/layout/includes/mixins/UI.pug +++ b/layout/includes/mixins/UI.pug @@ -53,4 +53,9 @@ mixin UI_NEW(posts) .content!= expert else .content!= article.description + + if theme.ad && theme.ad.index + if (index + 1) % 3 == 0 + .recent-post-item.ad_height!=theme.ad.index + - }) \ No newline at end of file diff --git a/layout/includes/recent-posts.pug b/layout/includes/recent-posts.pug index b5a27bd..3eeaaf5 100644 --- a/layout/includes/recent-posts.pug +++ b/layout/includes/recent-posts.pug @@ -56,4 +56,8 @@ each article , index in page.posts.data - content.length > theme.auto_excerpt.length ? expert += ' ...' : '' .content!= expert else - .content!= article.description \ No newline at end of file + .content!= article.description + + if theme.ad && theme.ad.index + if (index + 1) % 3 == 0 + .recent-post-item.ad_height!=theme.ad.index diff --git a/layout/includes/widget/card_ad.pug b/layout/includes/widget/card_ad.pug new file mode 100644 index 0000000..c05f774 --- /dev/null +++ b/layout/includes/widget/card_ad.pug @@ -0,0 +1,2 @@ +.card-widget.card-ad + != theme.ad.aside diff --git a/layout/includes/widget/card_webinfo.pug b/layout/includes/widget/card_webinfo.pug index 17903af..6691f7b 100644 --- a/layout/includes/widget/card_webinfo.pug +++ b/layout/includes/widget/card_webinfo.pug @@ -12,6 +12,10 @@ .webinfo-item .webinfo-runtime-name= _p('aside.card_webinfo.runtime_name') + " :" #webinfo-runtime-count.webinfo-runtime-count(start_date=theme.runtimeshow.start_date) + if theme.wordcount.total_wordcount + .webinfo-item + .webinfo-site-wordcount-name=_p('aside.card_webinfo.site_wordcount') + " :" + .webinfo-site-wordcount=totalcount(site) if theme.busuanzi.site_uv .webinfo-item .webinfo-site-uv-name= _p('aside.card_webinfo.site_uv_name') + " :" diff --git a/layout/includes/widget/index.pug b/layout/includes/widget/index.pug index 1bd1b48..dc789d4 100644 --- a/layout/includes/widget/index.pug +++ b/layout/includes/widget/index.pug @@ -7,6 +7,8 @@ if theme.aside.enable !=partial('includes/widget/card_announcement', {}, {cache:theme.fragment_cache}) if theme.aside.card_recent_post !=partial('includes/widget/card_recent_post', {}, {cache:theme.fragment_cache}) + if theme.ad && theme.ad.aside + !=partial('includes/widget/card_ad', {}, {cache:theme.fragment_cache}) if theme.aside.card_categories !=partial('includes/widget/card_categories', {}, {cache:theme.fragment_cache}) if theme.aside.card_tags diff --git a/layout/post.pug b/layout/post.pug index b76c765..0411099 100644 --- a/layout/post.pug +++ b/layout/post.pug @@ -8,13 +8,17 @@ block content if (theme.post_meta.post.tags) .post-meta__tag-list each item, index in page.tags.data - a(href=url_for(item.path)).post-meta__tags #[=item.name] + a(href=url_for(item.path)).post-meta__tags #[=item.name] !=partial('includes/share/index', {}, {cache:theme.fragment_cache}) if theme.reward.enable !=partial('includes/post/reward', {}, {cache:theme.fragment_cache}) + + //- ad + if theme.ad && theme.ad.post + .post-ad!=theme.ad.post + include includes/pagination.pug - if theme.related_post && theme.related_post.enable != related_posts(page,site.posts) if page.comments !== false diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index 7d48654..9d2d126 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -236,6 +236,13 @@ img:not([src]) font-weight: 700 font-size: 20px +.post-ad + margin: 2rem 0 !important + +.ad_height + height: auto !important + display: block !important + #content-inner, #footer animation: main 1s diff --git a/source/css/_layout/head.styl b/source/css/_layout/head.styl index 8991e0d..f38cf1c 100644 --- a/source/css/_layout/head.styl +++ b/source/css/_layout/head.styl @@ -103,6 +103,10 @@ #post-meta font-size: 95% + > .meta-secondline, + > .meta-thirdline + display inline + .word-count, #busuanzi_value_page_pv, .comment-count @@ -114,10 +118,7 @@ &__icon margin-right: .2rem - - &-pv-cv - display: inline-block - + a color: $light-grey transition: all .3s ease-out @@ -297,11 +298,12 @@ & > #post-meta font-size: 90% - & > span + .post-meta__categories display: none - - .post-meta-pv-cv + + .meta-thirdline display: block - .post-meta__separator:first-child - display: none \ No newline at end of file + .post-meta-pv-cv + .post-meta__separator:first-child + display: none \ No newline at end of file