breaking change:
1. 部分配置更改 feat: 1. 移除 messenger 聊天插件 2. 更新 fackbook 版本號 3. 增加 香港繁體、日文和韓語 4. 使用的新的複製api 代替舊的 5. 增加 umami 分析 6. 增加 umami 獲取訪問量/訪客數 7. snackbar 增加透明度 8. 文章頁下, nav fixed 下 顯示文章標題 improvement: 1. 代碼優化 2. 修改部分用語 3. 回復之前的相對時間邏輯 4. timeline tag 樣式優化 5. 優化 seo 6. 優化 artalk 的最新評論 fix: 1. tag-hide toggle 圓角問題 2. lazyload 為 false 時,artalk 無法正常加載評論的 bug 3. 修復 gallery 出現抖動的 bugpull/1564/head^2
parent
48212b9610
commit
d8a1fa6417
@ -0,0 +1,121 @@
|
|||||||
|
footer:
|
||||||
|
framework: フレームワーク
|
||||||
|
theme: テーマ
|
||||||
|
|
||||||
|
copy:
|
||||||
|
success: コピー成功
|
||||||
|
error: コピー失敗
|
||||||
|
noSupport: ブラウザが対応していません
|
||||||
|
|
||||||
|
page:
|
||||||
|
articles: 記事一覧
|
||||||
|
tag: タグ
|
||||||
|
category: カテゴリ
|
||||||
|
archives: アーカイブ
|
||||||
|
|
||||||
|
card_post_count: コメント数
|
||||||
|
|
||||||
|
no_title: タイトルなし
|
||||||
|
|
||||||
|
post:
|
||||||
|
created: 作成日
|
||||||
|
updated: 更新日
|
||||||
|
wordcount: 総文字数
|
||||||
|
min2read: 読む時間
|
||||||
|
min2read_unit: 分
|
||||||
|
page_pv: 閲覧数
|
||||||
|
comments: コメント数
|
||||||
|
copyright:
|
||||||
|
author: 著者
|
||||||
|
link: リンク
|
||||||
|
copyright_notice: 著作権表示
|
||||||
|
copyright_content: 'このブログのすべての記事は、<a href="%s">%s</a> ライセンスの下で提供されており、特に明記されていない限り、すべての権利を留保します。転載時には出典を明記してください: <a href="%s">%s</a>。'
|
||||||
|
recommend: 関連記事
|
||||||
|
edit: 編集
|
||||||
|
|
||||||
|
search:
|
||||||
|
title: 検索
|
||||||
|
load_data: データベースを読み込んでいます
|
||||||
|
input_placeholder: 記事を検索
|
||||||
|
algolia_search:
|
||||||
|
hits_empty: '${query} の検索結果が見つかりませんでした。'
|
||||||
|
hits_stats: '${hits} 件の結果が ${time}ms で見つかりました'
|
||||||
|
local_search:
|
||||||
|
hits_empty: '${query} の検索結果が見つかりませんでした。'
|
||||||
|
hits_stats: '${hits} 件の記事が見つかりました'
|
||||||
|
|
||||||
|
pagination:
|
||||||
|
prev: 前へ
|
||||||
|
next: 次へ
|
||||||
|
|
||||||
|
comment: コメント
|
||||||
|
|
||||||
|
aside:
|
||||||
|
articles: 記事
|
||||||
|
tags: タグ
|
||||||
|
categories: カテゴリ
|
||||||
|
card_announcement: お知らせ
|
||||||
|
card_categories: カテゴリ
|
||||||
|
card_tags: タグ
|
||||||
|
card_archives: アーカイブ
|
||||||
|
card_recent_post: 最近の記事
|
||||||
|
card_webinfo:
|
||||||
|
headline: サイト情報
|
||||||
|
article_name: 記事数
|
||||||
|
runtime:
|
||||||
|
name: 稼働時間
|
||||||
|
unit: 日
|
||||||
|
last_push_date:
|
||||||
|
name: 最終更新日
|
||||||
|
site_wordcount: 総文字数
|
||||||
|
site_uv_name: ユーザー数
|
||||||
|
site_pv_name: ページビュー数
|
||||||
|
more_button: もっと見る
|
||||||
|
card_newest_comments:
|
||||||
|
headline: 最新コメント
|
||||||
|
loading_text: ローディング中...
|
||||||
|
error: コメントを取得できませんでした。設定を確認してください。
|
||||||
|
zero: コメントがありません
|
||||||
|
image: 画像
|
||||||
|
link: リンク
|
||||||
|
code: コード
|
||||||
|
card_toc: 目次
|
||||||
|
card_post_series: シリーズ記事
|
||||||
|
|
||||||
|
date_suffix:
|
||||||
|
just: たった今
|
||||||
|
min: 分前
|
||||||
|
hour: 時間前
|
||||||
|
day: 日前
|
||||||
|
month: ヶ月前
|
||||||
|
|
||||||
|
donate: 寄付
|
||||||
|
share: 共有
|
||||||
|
|
||||||
|
rightside:
|
||||||
|
readmode_title: 読書モード
|
||||||
|
translate_title: 簡体字と繁体字の切り替え
|
||||||
|
night_mode_title: ライトモード/ダークモード切り替え
|
||||||
|
back_to_top: トップに戻る
|
||||||
|
toc: 目次
|
||||||
|
scroll_to_comment: コメントへ移動
|
||||||
|
setting: 設定
|
||||||
|
aside: シングルカラムとダブルカラムの切り替え
|
||||||
|
chat: チャット
|
||||||
|
|
||||||
|
copy_copyright:
|
||||||
|
author: 著者
|
||||||
|
link: リンク
|
||||||
|
source: ソース
|
||||||
|
info: 著作権は著者に帰属します。商業的利用の場合は著者に連絡して許可を得てください。非商業的利用の場合は出典を明記してください。
|
||||||
|
|
||||||
|
Snackbar:
|
||||||
|
chs_to_cht: 繁体字に切り替えました
|
||||||
|
cht_to_chs: 簡体字に切り替えました
|
||||||
|
day_to_night: ダークモードに切り替えました
|
||||||
|
night_to_day: ライトモードに切り替えました
|
||||||
|
|
||||||
|
loading: ローディング中...
|
||||||
|
load_more: もっと見る
|
||||||
|
|
||||||
|
error404: ページが見つかりません
|
@ -0,0 +1,121 @@
|
|||||||
|
footer:
|
||||||
|
framework: 프레임워크
|
||||||
|
theme: 테마
|
||||||
|
|
||||||
|
copy:
|
||||||
|
success: 복사 성공
|
||||||
|
error: 복사 실패
|
||||||
|
noSupport: 브라우저가 지원되지 않음
|
||||||
|
|
||||||
|
page:
|
||||||
|
articles: 모든 글
|
||||||
|
tag: 태그
|
||||||
|
category: 카테고리
|
||||||
|
archives: 아카이브
|
||||||
|
|
||||||
|
card_post_count: 댓글 수
|
||||||
|
|
||||||
|
no_title: 제목 없음
|
||||||
|
|
||||||
|
post:
|
||||||
|
created: 작성일
|
||||||
|
updated: 수정일
|
||||||
|
wordcount: 총 글자 수
|
||||||
|
min2read: 읽기 시간
|
||||||
|
min2read_unit: 분
|
||||||
|
page_pv: 조회수
|
||||||
|
comments: 댓글
|
||||||
|
copyright:
|
||||||
|
author: 작성자
|
||||||
|
link: 링크
|
||||||
|
copyright_notice: 저작권 고지
|
||||||
|
copyright_content: '이 블로그의 모든 글은 <a href="%s">%s</a> 라이선스를 따르며, 별도로 명시되지 않는 한 모든 권리를 보유합니다. 재배포 시 출처를 명시해 주세요: <a href="%s">%s</a>.'
|
||||||
|
recommend: 관련 글
|
||||||
|
edit: 편집
|
||||||
|
|
||||||
|
search:
|
||||||
|
title: 검색
|
||||||
|
load_data: 데이터베이스 로드 중
|
||||||
|
input_placeholder: 글 검색
|
||||||
|
algolia_search:
|
||||||
|
hits_empty: '${query}에 대한 결과를 찾을 수 없습니다.'
|
||||||
|
hits_stats: '${hits}개의 결과를 ${time}ms 만에 찾음'
|
||||||
|
local_search:
|
||||||
|
hits_empty: '${query}에 대한 결과를 찾을 수 없습니다.'
|
||||||
|
hits_stats: '${hits}개의 글을 찾음'
|
||||||
|
|
||||||
|
pagination:
|
||||||
|
prev: 이전
|
||||||
|
next: 다음
|
||||||
|
|
||||||
|
comment: 댓글
|
||||||
|
|
||||||
|
aside:
|
||||||
|
articles: 글
|
||||||
|
tags: 태그
|
||||||
|
categories: 카테고리
|
||||||
|
card_announcement: 공지
|
||||||
|
card_categories: 카테고리
|
||||||
|
card_tags: 태그
|
||||||
|
card_archives: 아카이브
|
||||||
|
card_recent_post: 최근 글
|
||||||
|
card_webinfo:
|
||||||
|
headline: 사이트 정보
|
||||||
|
article_name: 글 수
|
||||||
|
runtime:
|
||||||
|
name: 운영 시간
|
||||||
|
unit: 일
|
||||||
|
last_push_date:
|
||||||
|
name: 마지막 업데이트
|
||||||
|
site_wordcount: 총 글자 수
|
||||||
|
site_uv_name: 방문자 수
|
||||||
|
site_pv_name: 총 조회수
|
||||||
|
more_button: 더 보기
|
||||||
|
card_newest_comments:
|
||||||
|
headline: 최신 댓글
|
||||||
|
loading_text: 로딩 중...
|
||||||
|
error: 댓글을 가져올 수 없습니다. 설정을 확인해 주세요.
|
||||||
|
zero: 댓글 없음
|
||||||
|
image: 이미지
|
||||||
|
link: 링크
|
||||||
|
code: 코드
|
||||||
|
card_toc: 목차
|
||||||
|
card_post_series: 시리즈 글
|
||||||
|
|
||||||
|
date_suffix:
|
||||||
|
just: 방금
|
||||||
|
min: 분 전
|
||||||
|
hour: 시간 전
|
||||||
|
day: 일 전
|
||||||
|
month: 달 전
|
||||||
|
|
||||||
|
donate: 후원
|
||||||
|
share: 공유
|
||||||
|
|
||||||
|
rightside:
|
||||||
|
readmode_title: 읽기 모드
|
||||||
|
translate_title: 번체와 간체 전환
|
||||||
|
night_mode_title: 라이트/다크 모드 전환
|
||||||
|
back_to_top: 맨 위로
|
||||||
|
toc: 목차
|
||||||
|
scroll_to_comment: 댓글로 이동
|
||||||
|
setting: 설정
|
||||||
|
aside: 단일/이중 열 전환
|
||||||
|
chat: 채팅
|
||||||
|
|
||||||
|
copy_copyright:
|
||||||
|
author: 작성자
|
||||||
|
link: 링크
|
||||||
|
source: 출처
|
||||||
|
info: 저작권은 작성자에게 있습니다. 상업적 사용을 위해서는 작성자의 허가를 받아야 하며, 비상업적 사용 시에는 출처를 명시해 주세요.
|
||||||
|
|
||||||
|
Snackbar:
|
||||||
|
chs_to_cht: 번체로 전환되었습니다.
|
||||||
|
cht_to_chs: 간체로 전환되었습니다.
|
||||||
|
day_to_night: 다크 모드로 전환되었습니다.
|
||||||
|
night_to_day: 라이트 모드로 전환되었습니다.
|
||||||
|
|
||||||
|
loading: 로딩 중...
|
||||||
|
load_more: 더 보기
|
||||||
|
|
||||||
|
error404: 페이지를 찾을 수 없습니다.
|
@ -0,0 +1,121 @@
|
|||||||
|
footer:
|
||||||
|
framework: 框架
|
||||||
|
theme: 主題
|
||||||
|
|
||||||
|
copy:
|
||||||
|
success: 複製成功
|
||||||
|
error: 複製失敗
|
||||||
|
noSupport: 瀏覽器不支援
|
||||||
|
|
||||||
|
page:
|
||||||
|
articles: 全部文章
|
||||||
|
tag: 標籤
|
||||||
|
category: 分類
|
||||||
|
archives: 歸檔
|
||||||
|
|
||||||
|
card_post_count: 條評論
|
||||||
|
|
||||||
|
no_title: 無標題
|
||||||
|
|
||||||
|
post:
|
||||||
|
created: 發表於
|
||||||
|
updated: 更新於
|
||||||
|
wordcount: 字數統計
|
||||||
|
min2read: 閱讀時間
|
||||||
|
min2read_unit: 分鐘
|
||||||
|
page_pv: 瀏覽量
|
||||||
|
comments: 評論數
|
||||||
|
copyright:
|
||||||
|
author: 文章作者
|
||||||
|
link: 文章連結
|
||||||
|
copyright_notice: 版權聲明
|
||||||
|
copyright_content: '除特別聲明外,本博客所有文章均採用<a href="%s">%s</a> 授權協議。轉載請註明出處:<a href="%s">%s</a>。'
|
||||||
|
recommend: 相關文章
|
||||||
|
edit: 編輯
|
||||||
|
|
||||||
|
search:
|
||||||
|
title: 搜尋
|
||||||
|
load_data: 正在加載數據庫
|
||||||
|
input_placeholder: 搜尋文章
|
||||||
|
algolia_search:
|
||||||
|
hits_empty: '未找到相關內容:${query}'
|
||||||
|
hits_stats: '找到 ${hits} 條結果,耗時 ${time} 毫秒'
|
||||||
|
local_search:
|
||||||
|
hits_empty: '未找到相關內容:${query}'
|
||||||
|
hits_stats: '找到 ${hits} 篇文章'
|
||||||
|
|
||||||
|
pagination:
|
||||||
|
prev: 上一頁
|
||||||
|
next: 下一頁
|
||||||
|
|
||||||
|
comment: 評論
|
||||||
|
|
||||||
|
aside:
|
||||||
|
articles: 文章
|
||||||
|
tags: 標籤
|
||||||
|
categories: 分類
|
||||||
|
card_announcement: 公告
|
||||||
|
card_categories: 分類
|
||||||
|
card_tags: 標籤
|
||||||
|
card_archives: 歸檔
|
||||||
|
card_recent_post: 最新文章
|
||||||
|
card_webinfo:
|
||||||
|
headline: 網站資訊
|
||||||
|
article_name: 文章數目
|
||||||
|
runtime:
|
||||||
|
name: 運行時間
|
||||||
|
unit: 天
|
||||||
|
last_push_date:
|
||||||
|
name: 最後更新時間
|
||||||
|
site_wordcount: 總字數
|
||||||
|
site_uv_name: 訪客數
|
||||||
|
site_pv_name: 總瀏覽量
|
||||||
|
more_button: 查看更多
|
||||||
|
card_newest_comments:
|
||||||
|
headline: 最新評論
|
||||||
|
loading_text: 正在加載...
|
||||||
|
error: 無法取得評論,請確認配置是否正確
|
||||||
|
zero: 暫無評論
|
||||||
|
image: 圖片
|
||||||
|
link: 連結
|
||||||
|
code: 代碼
|
||||||
|
card_toc: 目錄
|
||||||
|
card_post_series: 系列文章
|
||||||
|
|
||||||
|
date_suffix:
|
||||||
|
just: 剛剛
|
||||||
|
min: 分鐘前
|
||||||
|
hour: 小時前
|
||||||
|
day: 天前
|
||||||
|
month: 個月前
|
||||||
|
|
||||||
|
donate: 贊助
|
||||||
|
share: 分享
|
||||||
|
|
||||||
|
rightside:
|
||||||
|
readmode_title: 閱讀模式
|
||||||
|
translate_title: 簡繁轉換
|
||||||
|
night_mode_title: 切換日夜模式
|
||||||
|
back_to_top: 回到頂部
|
||||||
|
toc: 目錄
|
||||||
|
scroll_to_comment: 前往評論
|
||||||
|
setting: 設定
|
||||||
|
aside: 單欄與雙欄切換
|
||||||
|
chat: 聊天
|
||||||
|
|
||||||
|
copy_copyright:
|
||||||
|
author: 作者
|
||||||
|
link: 連結
|
||||||
|
source: 來源
|
||||||
|
info: 版權屬於作者所有。商業用途請聯絡作者獲得授權,非商業用途請註明出處。
|
||||||
|
|
||||||
|
Snackbar:
|
||||||
|
chs_to_cht: 已切換為繁體中文
|
||||||
|
cht_to_chs: 已切換為簡體中文
|
||||||
|
day_to_night: 已切換為深色模式
|
||||||
|
night_to_day: 已切換為淺色模式
|
||||||
|
|
||||||
|
loading: 正在加載...
|
||||||
|
load_more: 加載更多
|
||||||
|
|
||||||
|
error404: 未找到頁面
|
@ -1,11 +1,13 @@
|
|||||||
link(rel="manifest" href=url_for(theme.pwa.manifest))
|
- const { manifest, theme_color, apple_touch_icon, favicon_32_32, favicon_16_16, mask_icon } = theme.pwa
|
||||||
if(theme.pwa.theme_color)
|
|
||||||
meta(name="msapplication-TileColor" content=theme.pwa.theme_color)
|
link(rel="manifest" href=url_for(manifest))
|
||||||
if(theme.pwa.apple_touch_icon)
|
if theme_color
|
||||||
link(rel="apple-touch-icon" sizes="180x180" href=url_for(theme.pwa.apple_touch_icon))
|
meta(name="msapplication-TileColor" content=theme_color)
|
||||||
if(theme.pwa.favicon_32_32)
|
if apple_touch_icon
|
||||||
link(rel="icon" type="image/png" sizes="32x32" href=url_for(theme.pwa.favicon_32_32))
|
link(rel="apple-touch-icon" sizes="180x180" href=url_for(apple_touch_icon))
|
||||||
if(theme.pwa.favicon_16_16)
|
if favicon_32_32
|
||||||
link(rel="icon" type="image/png" sizes="16x16" href=url_for(theme.pwa.favicon_16_16))
|
link(rel="icon" type="image/png" sizes="32x32" href=url_for(favicon_32_32))
|
||||||
if(theme.pwa.mask_icon)
|
if favicon_16_16
|
||||||
link(rel="mask-icon" href=url_for(theme.pwa.mask_icon) color="#5bbad5")
|
link(rel="icon" type="image/png" sizes="16x16" href=url_for(favicon_16_16))
|
||||||
|
if mask_icon
|
||||||
|
link(rel="mask-icon" href=url_for(mask_icon) color="#5bbad5")
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
each url, icon in theme.social
|
each url, icon in theme.social
|
||||||
a.social-icon(href=url_for(trim(url.split('||')[0])) target="_blank"
|
-
|
||||||
title=url.split('||')[1] === undefined ? '' : trim(url.split('||')[1]))
|
const [link, title, color] = url.split('||').map(i => trim(i))
|
||||||
i(class=icon style=url.split('||')[2] === undefined ? '' : `color: ${trim(url.split('||')[2]).replace(/[\'\"]/g, '')};`)
|
const href = url_for(link)
|
||||||
|
const iconStyle = color ? `color: ${color.replace(/[\'\"]/g, '')};` : ''
|
||||||
|
const iconTitle = title || ''
|
||||||
|
a.social-icon(href=href target="_blank" title=iconTitle)
|
||||||
|
i(class=icon style=iconStyle)
|
@ -1,3 +1,4 @@
|
|||||||
|
if theme.preloader.enable
|
||||||
if theme.preloader.source === 1
|
if theme.preloader.source === 1
|
||||||
include ./fullpage-loading.pug
|
include ./fullpage-loading.pug
|
||||||
else
|
else
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
- let { pageID, lang } = theme.messenger
|
|
||||||
- lang = theme.comments.use && theme.comments.use.includes('Facebook Comments') ? theme.facebook_comments.lang : lang
|
|
||||||
|
|
||||||
#fb-customer-chat.fb-customerchat(page_id=pageID attribution='biz_inbox')
|
|
||||||
|
|
||||||
script.
|
|
||||||
(() => {
|
|
||||||
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')
|
|
||||||
|
|
||||||
window.fbAsyncInit = function() {
|
|
||||||
FB.init({
|
|
||||||
xfbml: true,
|
|
||||||
version: 'v16.0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
(function(d, s, id) {
|
|
||||||
var js, fjs = d.getElementsByTagName(s)[0];
|
|
||||||
if (d.getElementById(id)) return;
|
|
||||||
js = d.createElement(s); js.id = id;
|
|
||||||
js.src = 'https://connect.facebook.net/!{lang}/sdk/xfbml.customerchat.js';
|
|
||||||
fjs.parentNode.insertBefore(js, fjs);
|
|
||||||
}(document, 'script', 'facebook-jssdk'));
|
|
||||||
|
|
||||||
const isChatBtn = !{theme.chat.rightside_button}
|
|
||||||
const isChatHideShow = !{theme.chat.button_hide_show}
|
|
||||||
|
|
||||||
if (isChatBtn) {
|
|
||||||
window.chatBtnFn = () => {
|
|
||||||
const isShow = document.querySelector('.fb_customer_chat_bounce_in_v2')
|
|
||||||
isShow ? FB.CustomerChat.hide() : FB.CustomerChat.show()
|
|
||||||
}
|
|
||||||
} else if (isChatHideShow) {
|
|
||||||
window.chatBtn = {
|
|
||||||
hide: () => {
|
|
||||||
FB.CustomerChat.hide()
|
|
||||||
},
|
|
||||||
show: () => {
|
|
||||||
FB.CustomerChat.show(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
|
|
@ -1,18 +1,10 @@
|
|||||||
case theme.math.use
|
case theme.math.use
|
||||||
when 'mathjax'
|
when 'mathjax'
|
||||||
if theme.math.per_page
|
if (theme.math.per_page && (is_post() || is_page())) || page.mathjax
|
||||||
if is_post() || is_page()
|
|
||||||
include ./mathjax.pug
|
|
||||||
else
|
|
||||||
if page.mathjax
|
|
||||||
include ./mathjax.pug
|
include ./mathjax.pug
|
||||||
|
|
||||||
when 'katex'
|
when 'katex'
|
||||||
if theme.math.per_page
|
if (theme.math.per_page && (is_post() || is_page())) || page.katex
|
||||||
if is_post() || is_page()
|
|
||||||
include ./katex.pug
|
|
||||||
else
|
|
||||||
if page.katex
|
|
||||||
include ./katex.pug
|
include ./katex.pug
|
||||||
|
|
||||||
if theme.mermaid.enable
|
if theme.mermaid.enable
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
script.
|
script.
|
||||||
(async () => {
|
(async () => {
|
||||||
const showKatex = () => {
|
const showKatex = () => {
|
||||||
const mathElements = document.querySelectorAll('#article-container .katex')
|
document.querySelectorAll('#article-container .katex').forEach(el => el.classList.add('katex-show'))
|
||||||
mathElements.length && mathElements.forEach((el) => {
|
|
||||||
el.classList.add('katex-show')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.katex_js_css) {
|
if (!window.katex_js_css) {
|
||||||
window.katex_js_css = true
|
window.katex_js_css = true
|
||||||
await btf.getCSS('!{url_for(theme.asset.katex)}')
|
await btf.getCSS('!{url_for(theme.asset.katex)}')
|
||||||
if (!{theme.math.katex.copy_tex}) await btf.getScript('!{url_for(theme.asset.katex_copytex)}')
|
if (!{theme.math.katex.copy_tex}) {
|
||||||
|
await btf.getScript('!{url_for(theme.asset.katex_copytex)}')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showKatex()
|
showKatex()
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
script.
|
||||||
|
window.newestComments = {
|
||||||
|
changeContent: content => {
|
||||||
|
if (content === '') return content
|
||||||
|
|
||||||
|
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
|
||||||
|
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
|
||||||
|
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||||
|
content = content.replace(/<code>.*?<\/code>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||||
|
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
||||||
|
|
||||||
|
if (content.length > 150) {
|
||||||
|
content = content.substring(0, 150) + '...'
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
},
|
||||||
|
|
||||||
|
generateHtml: (array, ele) => {
|
||||||
|
let result = ''
|
||||||
|
|
||||||
|
if (array.length) {
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
result += '<div class="aside-list-item">'
|
||||||
|
|
||||||
|
if (!{theme.aside.card_newest_comments.avatar} && array[i].avatar) {
|
||||||
|
const imgAttr = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
||||||
|
result += `<a href="${array[i].url}" class="thumbnail"><img ${imgAttr}="${array[i].avatar}" alt="${array[i].nick}"></a>`
|
||||||
|
}
|
||||||
|
|
||||||
|
result += `<div class="content">
|
||||||
|
<a class="comment" href="${array[i].url}" title="${array[i].content}">${array[i].content}</a>
|
||||||
|
<div class="name"><span>${array[i].nick} / </span><time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
|
||||||
|
</div></div>`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||||
|
}
|
||||||
|
|
||||||
|
ele.innerHTML = result
|
||||||
|
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||||
|
window.pjax && window.pjax.refresh(ele)
|
||||||
|
},
|
||||||
|
|
||||||
|
newestCommentInit: (name, getComment) => {
|
||||||
|
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||||
|
if ($dom) {
|
||||||
|
const data = btf.saveToLocal.get(name)
|
||||||
|
if (data) {
|
||||||
|
newestComments.generateHtml(JSON.parse(data), $dom)
|
||||||
|
} else {
|
||||||
|
getComment($dom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
run: (name, getComment) => {
|
||||||
|
newestComments.newestCommentInit(name, getComment)
|
||||||
|
btf.addGlobalFn('pjaxComplete', () => newestComments.newestCommentInit(name, getComment), name)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
- let { serverURL, website_id, option, UV_PV } = theme.umami_analytics
|
||||||
|
- const isServerURL = !!serverURL
|
||||||
|
- const baseURL = serverURL ? serverURL.replace(/\/$/, '') : 'https://cloud.umami.is'
|
||||||
|
- const apiUrl = serverURL ? serverURL.replace(/\/$/, '') + '/api' : 'https://api.umami.is/v1'
|
||||||
|
|
||||||
|
script.
|
||||||
|
(() => {
|
||||||
|
const option = !{JSON.stringify(option)}
|
||||||
|
const config = !{JSON.stringify(UV_PV)}
|
||||||
|
|
||||||
|
const runTrack = () => {
|
||||||
|
umami.track(props => ({ ...props, url: window.location.pathname, title: GLOBAL_CONFIG_SITE.title }))
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadUmamiJS = () => {
|
||||||
|
btf.getScript('!{baseURL}/script.js', {
|
||||||
|
'data-website-id': '!{website_id}',
|
||||||
|
'data-auto-track': 'false',
|
||||||
|
...option
|
||||||
|
}).then(runTrack)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getData = async (isPost) => {
|
||||||
|
const now = Date.now()
|
||||||
|
const keyUrl = isPost ? `&url=${window.location.pathname}` : ''
|
||||||
|
const headerList = { 'Accept': 'application/json' }
|
||||||
|
if (!{isServerURL}) headerList['Authorization'] = `Bearer ${config.token}`
|
||||||
|
else headerList['x-umami-api-key'] = config.token
|
||||||
|
const res = await fetch(`!{apiUrl}/websites/!{website_id}/stats?startAt=0000000000&endAt=${now}${keyUrl}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: headerList
|
||||||
|
})
|
||||||
|
return await res.json()
|
||||||
|
}
|
||||||
|
|
||||||
|
const insertData = async () => {
|
||||||
|
try {
|
||||||
|
if (GLOBAL_CONFIG_SITE.isPost && config.page_pv) {
|
||||||
|
const pagePV = document.getElementById('umamiPV')
|
||||||
|
if (pagePV) {
|
||||||
|
const data = await getData(true)
|
||||||
|
pagePV.textContent = data.pageviews.value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const data = (config.site_uv || config.site_pv) && await getData()
|
||||||
|
if (config.site_uv) {
|
||||||
|
const siteUV = document.getElementById('umami-site-uv')
|
||||||
|
if (siteUV) siteUV.textContent = data.visitors.value
|
||||||
|
}
|
||||||
|
if (config.site_pv) {
|
||||||
|
const sitePV = document.getElementById('umami-site-pv')
|
||||||
|
if (sitePV) sitePV.textContent = data.pageviews.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load Umami Analytics:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btf.addGlobalFn('pjaxComplete', runTrack, 'umami_analytics_run_track')
|
||||||
|
btf.addGlobalFn('pjaxComplete', insertData, 'umami_analytics_insert')
|
||||||
|
|
||||||
|
loadUmamiJS()
|
||||||
|
insertData()
|
||||||
|
})()
|
Loading…
Reference in New Issue