Merge branch 'release_v4.1.0'
Some checks failed
sync-2-gitee / sync-2-gitee (push) Failing after 3s

This commit is contained in:
凡梦星尘 2022-07-27 21:43:21 +08:00
commit 403a2e6f54
76 changed files with 671 additions and 579 deletions

15
.gitignore vendored
View File

@ -1,6 +1,17 @@
# Ignore files in Hugo NexT theme # Ignore files in Hugo NexT theme
exampleSite/ exampleSite/*
# Exclude special files in content folder
!exampleSite/content !exampleSite/content
!exampleSite/start.sh exampleSite/content/*
!exampleSite/content/archives
!exampleSite/content/post
# Exclude special files in static folder
!exampleSite/static
# Exclude special files
!exampleSite/config.yaml !exampleSite/config.yaml
!exampleSite/start.sh

View File

@ -1 +1 @@
4.0.0 4.1.0

View File

@ -131,9 +131,9 @@ $gitter_enable : {{ $P.gitter.enable }};
// Comment // Comment
//$disqusjs_enable : {{ $P.disqusjs.enable }}; //$disqusjs_enable : {{ $P.disqusjs.enable }};
$disqusjs_enable : false; $disqusjs_enable : false;
$livere_enable : {{ isset $P.livere "uid" }}; $livere_enable : {{ isset $P "livere" }};
$utterances_enable : {{ isset $P.utterances "utterances" }}; $utterances_enable : {{ isset $P "utterances" }};
$waline_enable : {{ isset $P.waline "serverurl" }}; $waline_enable : {{ isset $P "waline" }};
{{- with .Site.Params.comments }} {{- with .Site.Params.comments }}
{{- $tce := and (isset . "nav") (and .storage (gt (len .nav) 1)) }} {{- $tce := and (isset . "nav") (and .storage (gt (len .nav) 1)) }}
$two_comments_enable : {{ $tce }}; $two_comments_enable : {{ $tce }};

View File

@ -52,5 +52,5 @@ document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('pjax:success', scrollToMark); document.addEventListener('pjax:success', scrollToMark);
}; };
init(CONFIG.bookmark.save); init(NexT.CONFIG.bookmark.save);
}); });

View File

@ -7,13 +7,13 @@
element.addEventListener('click', () => { element.addEventListener('click', () => {
commentButton.forEach(active => active.classList.toggle('active', active === element)); commentButton.forEach(active => active.classList.toggle('active', active === element));
document.querySelectorAll('.comment-position').forEach(active => active.classList.toggle('active', active.classList.contains(commentClass))); document.querySelectorAll('.comment-position').forEach(active => active.classList.toggle('active', active.classList.contains(commentClass)));
if (CONFIG.comments.storage) { if (NexT.CONFIG.comments.storage) {
localStorage.setItem('comments_active', commentClass); localStorage.setItem('comments_active', commentClass);
} }
}); });
}); });
let { activeClass } = CONFIG.comments; let { activeClass } = NexT.CONFIG.comments;
if (CONFIG.comments.storage) { if (NexT.CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass; activeClass = localStorage.getItem('comments_active') || activeClass;
} }
if (activeClass) { if (activeClass) {

View File

@ -1,8 +1,8 @@
/* global CONFIG */ /* global CONFIG */
window.addEventListener('tabs:register', () => { window.addEventListener('tabs:register', () => {
let { activeClass } = CONFIG.comments; let { activeClass } = NexT.CONFIG.comments;
if (CONFIG.comments.storage) { if (NexT.CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass; activeClass = localStorage.getItem('comments_active') || activeClass;
} }
if (activeClass) { if (activeClass) {
@ -12,7 +12,7 @@ window.addEventListener('tabs:register', () => {
} }
} }
}); });
if (CONFIG.comments.storage) { if (NexT.CONFIG.comments.storage) {
window.addEventListener('tabs:click', event => { window.addEventListener('tabs:click', event => {
if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return; if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
const commentClass = event.target.classList[1]; const commentClass = event.target.classList[1];

View File

@ -1,51 +1,67 @@
if (!window.NexT) window.NexT = {}; if (!window.NexT) window.NexT = {};
(function() { (function() {
const className = 'next-config';
const siteConfig = { const staticConfig = {};
"hostname" : "{{ .Site.BaseURL }}", let variableConfig = {};
"root" : "/",
"images" : "{{ .Site.Params.images }}", const parse = text => JSON.parse(text || '{}');
"scheme" : "{{ .Site.Params.scheme }}",
"darkmode" : {{ .Site.Params.darkmode }}, const update = name => {
"version" : "{{ .Site.Data.config.version }}", const targetEle = document.querySelector(`.${className}[data-name="${name}"]`);
"sidebar" : {{ .Site.Params.sidebar | jsonify }}, if (!targetEle) return;
"copybtn" : {{ .Site.Params.codeblock.copyBtn }}, const parsedConfig = parse(targetEle.text);
"bookmark" : {{ .Site.Params.bookmark | jsonify }}, if (name === 'main') {
"comments" : {{ .Site.Params.comments | jsonify }}, Object.assign(staticConfig, parsedConfig);
"lazyload" : {{ .Site.Params.lazyload }}, } else {
"pangu" : {{ .Site.Params.pangu }}, variableConfig[name] = parsedConfig;
"stickytabs" : {{ .Site.Params.tabs.sticky }},
"motion" : {{ .Site.Params.motion | jsonify }},
// TODO Find prismjs
//"prism" : "",
"i18n" : {
"placeholder" : "",
"empty" : "${query}",
"hits_time" : "'${hits}', '${time}'",
"hits" : "${hits}"
},
{{- if .Site.Params.algoliaSearch.enable }}
// TODO
"algolia" : {
"appID" : "",
"apiKey" : "",
"indexName" : "",
"hits" : ""
} }
{{- end }}
{{- if .Site.Params.localSearch.enable }}
// TODO
"path" : "/search.json",
"localsearch": {{ .Site.Params.localSearch | jsonify }},
{{- end }}
"lang" : "{{ .Site.LanguageCode }}",
"permalink" : "{{ .Page.Permalink | absURL }}",
"title" : "{{ .Page.Title }}",
"isHome" : {{ .IsHome }},
"isPage" : {{ .IsPage }}
}; };
window.CONFIG = new Proxy(siteConfig, {}); update('main');
window.NexT.CONFIG = new Proxy({}, {
get(overrideConfig, name) {
let existing;
if (name in staticConfig) {
existing = staticConfig[name];
} else {
if (!(name in variableConfig)) update(name);
existing = variableConfig[name];
}
// For unset override and mixable existing
if (!(name in overrideConfig) && typeof existing === 'object') {
// Get ready to mix.
overrideConfig[name] = {};
}
if (name in overrideConfig) {
const override = overrideConfig[name];
// When mixable
if (typeof override === 'object' && typeof existing === 'object') {
// Mix, proxy changes to the override.
return new Proxy({ ...existing, ...override }, {
set(target, prop, value) {
target[prop] = value;
override[prop] = value;
return true;
}
});
}
return override;
}
// Only when not mixable and override hasn't been set.
return existing;
}
});
// TODO
// document.addEventListener('pjax:success', () => {
// variableConfig = {};
// });
})(); })();

View File

@ -10,12 +10,12 @@ NexT.motion.integrator = {
}, },
add: function(fn) { add: function(fn) {
const sequence = fn(); const sequence = fn();
if (CONFIG.motion.async) this.queue.push(sequence); if (NexT.CONFIG.motion.async) this.queue.push(sequence);
else this.queue = this.queue.concat(sequence); else this.queue = this.queue.concat(sequence);
return this; return this;
}, },
bootstrap: function() { bootstrap: function() {
if (!CONFIG.motion.async) this.queue = [this.queue]; if (!NexT.CONFIG.motion.async) this.queue = [this.queue];
this.queue.forEach(sequence => { this.queue.forEach(sequence => {
const timeline = window.anime.timeline({ const timeline = window.anime.timeline({
duration: 200, duration: 200,
@ -52,12 +52,12 @@ NexT.motion.middleWares = {
} }
pushToSequence('header.header'); pushToSequence('header.header');
CONFIG.scheme === 'Mist' && getMistLineSettings('.logo-line'); NexT.CONFIG.scheme === 'Mist' && getMistLineSettings('.logo-line');
CONFIG.scheme === 'Muse' && pushToSequence('.custom-logo-image'); NexT.CONFIG.scheme === 'Muse' && pushToSequence('.custom-logo-image');
pushToSequence('.site-title'); pushToSequence('.site-title');
pushToSequence('.site-brand-container .toggle', true); pushToSequence('.site-brand-container .toggle', true);
pushToSequence('.site-subtitle'); pushToSequence('.site-subtitle');
(CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') && pushToSequence('.custom-logo-image'); (NexT.CONFIG.scheme === 'Pisces' || NexT.CONFIG.scheme === 'Gemini') && pushToSequence('.custom-logo-image');
document.querySelectorAll('.menu-item').forEach(targets => { document.querySelectorAll('.menu-item').forEach(targets => {
sequence.push({ sequence.push({
@ -82,7 +82,7 @@ NexT.motion.middleWares = {
postList: function() { postList: function() {
const sequence = []; const sequence = [];
const { postblock, postheader, postbody, collheader } = CONFIG.motion.transition; const { postblock, postheader, postbody, collheader } = NexT.CONFIG.motion.transition;
function animate(animation, selector) { function animate(animation, selector) {
if (!animation) return; if (!animation) return;
@ -105,9 +105,9 @@ NexT.motion.middleWares = {
sidebar: function() { sidebar: function() {
const sidebar = document.querySelector('.sidebar'); const sidebar = document.querySelector('.sidebar');
const sidebarTransition = CONFIG.motion.transition.sidebar; const sidebarTransition = NexT.CONFIG.motion.transition.sidebar;
// Only for Pisces | Gemini. // Only for Pisces | Gemini.
if (sidebarTransition && (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini')) { if (sidebarTransition && (NexT.CONFIG.scheme === 'Pisces' || NexT.CONFIG.scheme === 'Gemini')) {
return [{ return [{
targets : sidebar, targets : sidebar,
complete: () => sidebar.classList.add('animated', sidebarTransition) complete: () => sidebar.classList.add('animated', sidebarTransition)

View File

@ -4,8 +4,8 @@ NexT.boot = {};
NexT.boot.registerEvents = function() { NexT.boot.registerEvents = function() {
NexT.utils.registerScrollPercent(); // NexT.utils.registerScrollPercent();
NexT.utils.registerCanIUseTag(); // NexT.utils.registerCanIUseTag();
// Mobile top menu bar. // Mobile top menu bar.
document.querySelector('.site-nav-toggle .toggle').addEventListener('click', event => { document.querySelector('.site-nav-toggle .toggle').addEventListener('click', event => {
@ -33,33 +33,41 @@ NexT.boot.registerEvents = function() {
NexT.boot.refresh = function() { NexT.boot.refresh = function() {
if (!NexT.CONFIG.page.isPage) return;
NexT.utils.registerSidebarTOC();
NexT.utils.replacePostCRLink();
NexT.utils.registerCopyCode();
NexT.utils.registerPostReward();
if(NexT.CONFIG.page.comments) {
NexT.utils.initCommontesDispaly();
NexT.utils.registerCommonSwitch();
} else {
NexT.utils.hideCommontes();
}
//TODO
/** /**
* Register JS handlers by condition option. * Register JS handlers by condition option.
* Need to add config option in Front-End at 'scripts/helpers/next-config.js' file. * Need to add config option in Front-End at 'scripts/helpers/next-config.js' file.
*/ */
//CONFIG.prism && window.Prism.highlightAll(); //NexT.CONFIG.prism && window.Prism.highlightAll();
/*CONFIG.mediumzoom && window.mediumZoom('.post-body :not(a) > img, .post-body > img', { /*NexT.CONFIG.mediumzoom && window.mediumZoom('.post-body :not(a) > img, .post-body > img', {
background: 'var(--content-bg-color)' background: 'var(--content-bg-color)'
});*/ });*/
CONFIG.lazyload && window.lozad('.post-body img').observe(); // NexT.CONFIG.lazyload && window.lozad('.post-body img').observe();
CONFIG.pangu && window.pangu.spacingPage(); // NexT.CONFIG.pangu && window.pangu.spacingPage();
/*NexT.utils.registerTabsTag();
CONFIG.isPage && NexT.utils.replacePostCRLink(); NexT.utils.registerActiveMenuItem();
CONFIG.isPage && CONFIG.copybtn && NexT.utils.registerCopyCode();
NexT.utils.registerTabsTag();
/*NexT.utils.registerActiveMenuItem();
NexT.utils.registerLangSelect();*/ NexT.utils.registerLangSelect();*/
CONFIG.isPage && NexT.utils.registerSidebarTOC(); /*NexT.utils.wrapTableWithBox();
CONFIG.isPage && NexT.utils.registerPostReward(); NexT.utils.registerVideoIframe();*/
CONFIG.isPage && NexT.utils.initCommontesDispaly();
CONFIG.isPage && NexT.utils.registerCommonSwitch();
NexT.utils.wrapTableWithBox();
NexT.utils.registerVideoIframe();
}; };
NexT.boot.motion = function() { NexT.boot.motion = function() {
// Define Motion Sequence & Bootstrap Motion. // Define Motion Sequence & Bootstrap Motion.
if (CONFIG.motion.enable) { if (NexT.CONFIG.motion.enable) {
NexT.motion.integrator NexT.motion.integrator
.add(NexT.motion.middleWares.header) .add(NexT.motion.middleWares.header)
.add(NexT.motion.middleWares.postList) .add(NexT.motion.middleWares.postList)
@ -72,6 +80,6 @@ NexT.boot.motion = function() {
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
NexT.boot.registerEvents(); NexT.boot.registerEvents();
NexT.boot.refresh();
NexT.boot.motion(); NexT.boot.motion();
NexT.boot.refresh();
}); });

View File

@ -11,21 +11,21 @@ const pjax = new Pjax({
], ],
analytics: false, analytics: false,
cacheBust: false, cacheBust: false,
scrollTo : !CONFIG.bookmark.enable scrollTo : !NexT.CONFIG.bookmark.enable
}); });
document.addEventListener('pjax:success', () => { document.addEventListener('pjax:success', () => {
pjax.executeScripts(document.querySelectorAll('script[data-pjax]')); pjax.executeScripts(document.querySelectorAll('script[data-pjax]'));
NexT.boot.refresh(); NexT.boot.refresh();
// Define Motion Sequence & Bootstrap Motion. // Define Motion Sequence & Bootstrap Motion.
if (CONFIG.motion.enable) { if (NexT.CONFIG.motion.enable) {
NexT.motion.integrator NexT.motion.integrator
.init() .init()
.add(NexT.motion.middleWares.subMenu) .add(NexT.motion.middleWares.subMenu)
.add(NexT.motion.middleWares.postList) .add(NexT.motion.middleWares.postList)
.bootstrap(); .bootstrap();
} }
if (CONFIG.sidebar.display !== 'remove') { if (NexT.CONFIG.sidebar.display !== 'remove') {
const hasTOC = document.querySelector('.post-toc'); const hasTOC = document.querySelector('.post-toc');
document.querySelector('.sidebar-inner').classList.toggle('sidebar-nav-active', hasTOC); document.querySelector('.sidebar-inner').classList.toggle('sidebar-nav-active', hasTOC);
NexT.utils.activateSidebarPanel(hasTOC ? 0 : 1); NexT.utils.activateSidebarPanel(hasTOC ? 0 : 1);

View File

@ -2,7 +2,7 @@
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const isRight = CONFIG.sidebar.position === 'right'; const isRight = NexT.CONFIG.sidebar.position === 'right';
const sidebarToggleMotion = { const sidebarToggleMotion = {
mouse: {}, mouse: {},
@ -46,7 +46,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.body.classList.remove('sidebar-active'); document.body.classList.remove('sidebar-active');
} }
}; };
if (CONFIG.sidebar.display !== 'remove') sidebarToggleMotion.init(); if (NexT.CONFIG.sidebar.display !== 'remove') sidebarToggleMotion.init();
function updateFooterPosition() { function updateFooterPosition() {
const footer = document.querySelector('.footer'); const footer = document.querySelector('.footer');

View File

@ -0,0 +1,36 @@
document.addEventListener('DOMContentLoaded', () => {
const element = '.artalk-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.artalk
|| !NexT.utils.checkDOMExist(element)) return;
const artalk_css = NexT.utils.getCDNResource(NexT.CONFIG.artalk.css);
NexT.utils.getStyle(artalk_css, null);
const artalk_js = NexT.utils.getCDNResource(NexT.CONFIG.artalk.js);
const {
site,
placeholder,
server,
} = NexT.CONFIG.artalk.cfg;
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(artalk_js, {
}))
.then(() => {
new Artalk({
el : element,
pageKey : NexT.CONFIG.permalink,
pageTitle : NexT.CONFIG.title,
server : server,
site : site,
locale : NexT.CONFIG.lang,
placeholder : placeholder,
darkMode : 'auto'
});
NexT.utils.hiddeLodingCmp(element);
});
});

View File

@ -1,39 +0,0 @@
/* global NexT, CONFIG */
document.addEventListener('page:loaded', () => {
const { appid, appkey } = CONFIG.changyan;
const mainJs = 'https://cy-cdn.kuaizhan.com/upload/changyan.js';
const countJs = `https://cy-cdn.kuaizhan.com/upload/plugins/plugins.list.count.js?clientId=${appid}`;
// Get the number of comments
setTimeout(() => {
return NexT.utils.getScript(countJs, {
attributes: {
async: true,
id : 'cy_cmt_num'
}
});
}, 0);
// When scroll to comment section
if (CONFIG.page.comments && !CONFIG.page.isHome) {
NexT.utils.loadComments('#SOHUCS')
.then(() => {
return NexT.utils.getScript(mainJs, {
attributes: {
async: true
}
});
})
.then(() => {
window.changyan.api.config({
appid,
conf: appkey
});
})
.catch(error => {
// eslint-disable-next-line no-console
console.error('Failed to load Changyan', error);
});
}
});

View File

@ -1,41 +0,0 @@
/* global NexT, CONFIG, DISQUS */
document.addEventListener('page:loaded', () => {
if (CONFIG.disqus.count) {
const loadCount = () => {
NexT.utils.getScript(`https://${CONFIG.disqus.shortname}.disqus.com/count.js`, {
attributes: { id: 'dsq-count-scr' }
});
};
// defer loading until the whole page loading is completed
window.addEventListener('load', loadCount, false);
}
if (CONFIG.page.comments) {
// `disqus_config` should be a global variable
// See https://help.disqus.com/en/articles/1717084-javascript-configuration-variables
window.disqus_config = function() {
this.page.url = CONFIG.page.permalink;
this.page.identifier = CONFIG.page.path;
this.page.title = CONFIG.page.title;
if (CONFIG.disqus.i18n.disqus !== 'disqus') {
this.language = CONFIG.disqus.i18n.disqus;
}
};
NexT.utils.loadComments('#disqus_thread').then(() => {
if (window.DISQUS) {
DISQUS.reset({
reload: true,
config: window.disqus_config
});
} else {
NexT.utils.getScript(`https://${CONFIG.disqus.shortname}.disqus.com/embed.js`, {
attributes: { dataset: { timestamp: '' + +new Date() } }
});
}
});
}
});

View File

@ -1,18 +0,0 @@
/* global NexT, CONFIG, DisqusJS */
document.addEventListener('page:loaded', () => {
if (!CONFIG.page.comments) return;
NexT.utils.loadComments('#disqus_thread')
.then(() => NexT.utils.getScript(CONFIG.disqusjs.js, { condition: window.DisqusJS }))
.then(() => {
window.dsqjs = new DisqusJS({
api : CONFIG.disqusjs.api || 'https://disqus.com/api/',
apikey : CONFIG.disqusjs.apikey,
shortname : CONFIG.disqusjs.shortname,
url : CONFIG.page.permalink,
identifier: CONFIG.page.path,
title : CONFIG.page.title
});
});
});

View File

@ -0,0 +1,41 @@
document.addEventListener('DOMContentLoaded', () => {
const element = '.giscus-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.giscus
|| !NexT.utils.checkDOMExist(element)) return;
const {
category,
categoryid,
emit,
inputposition,
mapping,
reactions,
repo,
repoid,
theme } = NexT.CONFIG.giscus.cfg;
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(NexT.CONFIG.giscus.js, {
attributes: {
'async' : true,
'crossorigin' : 'anonymous',
'data-repo' : repo,
'data-repo-id' : repoid,
'data-category' : category,
'data-category-id' : categoryid,
'data-mapping' : mapping,
'data-reactions-enabled' : reactions ? 1:0,
'data-emit-metadata' : emit ? 1:0,
'data-input-position' : inputposition,
'data-theme' : theme,
'data-lang' : NexT.CONFIG.lang,
'data-loading' : 'lazy'
},
parentNode: document.querySelector(element)
}));
NexT.utils.hiddeLodingCmp(element);
});

View File

@ -1,24 +0,0 @@
/* global NexT, CONFIG, Gitalk */
document.addEventListener('page:loaded', () => {
if (!CONFIG.page.comments) return;
NexT.utils.loadComments('.gitalk-container')
.then(() => NexT.utils.getScript(CONFIG.gitalk.js, {
condition: window.Gitalk
}))
.then(() => {
const gitalk = new Gitalk({
clientID : CONFIG.gitalk.client_id,
clientSecret : CONFIG.gitalk.client_secret,
repo : CONFIG.gitalk.repo,
owner : CONFIG.gitalk.github_id,
admin : [CONFIG.gitalk.admin_user],
id : CONFIG.gitalk.path_md5,
proxy : CONFIG.gitalk.proxy,
language : CONFIG.gitalk.language || window.navigator.language,
distractionFreeMode: CONFIG.gitalk.distraction_free_mode
});
gitalk.render(document.querySelector('.gitalk-container'));
});
});

View File

@ -1,15 +0,0 @@
/* global NexT, CONFIG */
document.addEventListener('page:loaded', () => {
if (!CONFIG.page.comments) return;
NexT.utils.loadComments('#isso-thread')
.then(() => NexT.utils.getScript(`${CONFIG.isso}js/embed.min.js`, {
attributes: {
dataset: {
isso: `${CONFIG.isso}`
}
},
parentNode: document.querySelector('#isso-thread')
}));
});

View File

@ -1,19 +1,18 @@
/* global NexT, CONFIG, LivereTower */ document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('page:loaded', () => { const element = '#lv-container';
if (!CONFIG.page.comments) return; if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.livere
|| !NexT.utils.checkDOMExist(element)) return;
NexT.utils.loadComments('#lv-container').then(() => { NexT.utils.loadComments(element).then(() => {
window.livereOptions = { NexT.utils.getScript(NexT.CONFIG.livere.js, {
refer: CONFIG.page.path.replace(/index\.html$/, '')
};
if (typeof LivereTower === 'function') return;
NexT.utils.getScript('https://cdn-city.livere.com/js/embed.dist.js', {
attributes: { attributes: {
async: true async: true
} },
}); parentNode: document.querySelector(element)
});
NexT.utils.hiddeLodingCmp(element);
}); });
}); });

View File

@ -1,17 +1,27 @@
/* global NexT, CONFIG */ document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('page:loaded', () => { const element = '.utterances-container';
if (!CONFIG.page.comments) return; if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.utterances
|| !NexT.utils.checkDOMExist(element)) return;
NexT.utils.loadComments('.utterances-container') const {
.then(() => NexT.utils.getScript('https://utteranc.es/client.js', { repo,
issueterm,
label,
theme } = NexT.CONFIG.utterances.cfg;
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(NexT.CONFIG.utterances.js, {
attributes: { attributes: {
async : true, 'async' : true,
crossOrigin : 'anonymous', 'crossorigin' : 'anonymous',
'repo' : CONFIG.utterances.repo, 'repo' : repo,
'issue-term': CONFIG.utterances.issue_term, 'issue-term' : issueterm,
'theme' : CONFIG.utterances.theme 'theme' : theme
}, },
parentNode: document.querySelector('.utterances-container') parentNode: document.querySelector(element)
})); }));
NexT.utils.hiddeLodingCmp(element);
}); });

View File

@ -0,0 +1,48 @@
document.addEventListener('DOMContentLoaded', () => {
const element = '.waline-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.waline
|| !NexT.utils.checkDOMExist(element)) return;
const {
emoji,
imguploader,
pageview,
placeholder,
requiredmeta,
serverurl,
wordlimit
} = NexT.CONFIG.waline.cfg;
const waline_css = NexT.utils.getCDNResource(NexT.CONFIG.waline.css);
NexT.utils.getStyle(waline_css, null);
const waline_js = NexT.utils.getCDNResource(NexT.CONFIG.waline.js);
const locale = {
placeholder: placeholder
};
NexT.utils.loadComments(element)
.then(() => NexT.utils.getScript(waline_js, {
}))
.then(() => {
Waline.init({
locale,
el : element,
pageview : pageview,
emoji : emoji,
imageUploader : imguploader,
wordLimit : wordlimit,
requiredMeta : requiredmeta,
serverURL : serverurl,
lang : NexT.CONFIG.lang,
dark : "auto"
});
NexT.utils.hiddeLodingCmp(element);
});
});

16
assets/js/third-party/share/addthis.js vendored Normal file
View File

@ -0,0 +1,16 @@
document.addEventListener('DOMContentLoaded', () => {
const element = '.addthis_inline_share_toolbox';
if (!NexT.CONFIG.addthis || !NexT.utils.checkDOMExist(element)) return;
const addthis_js = NexT.CONFIG.addthis.js + '?pubid=' + NexT.CONFIG.addthis.cfg.pubid;
NexT.utils.loadComments(element).then(() => {
NexT.utils.getScript(addthis_js, {
attributes: {
async: true
},
parentNode: document.querySelector(element)
});
});
});

View File

@ -23,8 +23,31 @@ HTMLElement.prototype.wrap = function(wrapper) {
NexT.utils = { NexT.utils = {
checkDOMExist: function(selector) {
return document.querySelector(selector) != null;
},
getCDNResource: function(res) {
let { plugins, router } = NexT.CONFIG.vendor;
let { name, version, file, alias } = res;
let npm_name = name;
let res_src = '';
switch(plugins) {
case 'cdnjs':
let cdnjs_name = alias || name;
let cdnjs_file = file.replace(/\.js$/, '.min.js').replace(/^(dist|lib|source\/js|)\/(browser\/|)/, '');
res_src = `${router}/${cdnjs_name}/${version}/${cdnjs_file}`
break;
default:
res_src = `${router}/${npm_name}@${version}/${file}`
}
return res_src;
},
replacePostCRLink: function() { replacePostCRLink: function() {
if (CONFIG.hostname.startsWith('http')) return; if (NexT.CONFIG.hostname.startsWith('http')) return;
// Try to support mutli domain without base URL sets. // Try to support mutli domain without base URL sets.
let href = window.location.href; let href = window.location.href;
if (href.indexOf('#')>-1){ if (href.indexOf('#')>-1){
@ -40,8 +63,10 @@ NexT.utils = {
* One-click copy code support. * One-click copy code support.
*/ */
registerCopyCode: function() { registerCopyCode: function() {
if (!NexT.CONFIG.copybtn) return;
let figure = document.querySelectorAll('.highlight pre'); let figure = document.querySelectorAll('.highlight pre');
if (figure.length === 0 || !CONFIG.copybtn) return; if (figure.length === 0 || !NexT.CONFIG.copybtn) return;
figure.forEach(element => { figure.forEach(element => {
let cn = element.querySelector('code').className; let cn = element.querySelector('code').className;
// TODO seems hard code need find other ways fixed it. // TODO seems hard code need find other ways fixed it.
@ -170,13 +195,14 @@ NexT.utils = {
// https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers // https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers
const tActive = document.getElementById(element.querySelector('a').getAttribute('href').replace('#', '')); const tActive = document.getElementById(element.querySelector('a').getAttribute('href').replace('#', ''));
[...tActive.parentNode.children].forEach(target => { [...tActive.parentNode.children].forEach(target => {
// Array.prototype.slice.call(tActive.parentNode.children).forEach(target => {
target.classList.toggle('active', target === tActive); target.classList.toggle('active', target === tActive);
}); });
// Trigger event // Trigger event
tActive.dispatchEvent(new Event('tabs:click', { tActive.dispatchEvent(new Event('tabs:click', {
bubbles: true bubbles: true
})); }));
if (!CONFIG.stickytabs) return; if (!NexT.CONFIG.stickytabs) return;
const offset = nav.parentNode.getBoundingClientRect().top + window.scrollY + 10; const offset = nav.parentNode.getBoundingClientRect().top + window.scrollY + 10;
window.anime({ window.anime({
targets : document.scrollingElement, targets : document.scrollingElement,
@ -204,7 +230,7 @@ NexT.utils = {
/*registerActiveMenuItem: function() { /*registerActiveMenuItem: function() {
document.querySelectorAll('.menu-item a[href]').forEach(target => { document.querySelectorAll('.menu-item a[href]').forEach(target => {
const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', ''); const isSamePath = target.pathname === location.pathname || target.pathname === location.pathname.replace('index.html', '');
const isSubPath = !CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname); const isSubPath = !NexT.CONFIG.root.startsWith(target.pathname) && location.pathname.startsWith(target.pathname);
target.classList.toggle('menu-item-active', target.hostname === location.hostname && (isSamePath || isSubPath)); target.classList.toggle('menu-item-active', target.hostname === location.hostname && (isSamePath || isSubPath));
}); });
}, },
@ -212,7 +238,7 @@ NexT.utils = {
registerLangSelect: function() { registerLangSelect: function() {
const selects = document.querySelectorAll('.lang-select'); const selects = document.querySelectorAll('.lang-select');
selects.forEach(sel => { selects.forEach(sel => {
sel.value = CONFIG.page.lang; sel.value = NexT.CONFIG.page.lang;
sel.addEventListener('change', () => { sel.addEventListener('change', () => {
const target = sel.options[sel.selectedIndex]; const target = sel.options[sel.selectedIndex];
document.querySelectorAll('.lang-select-label span').forEach(span => { document.querySelectorAll('.lang-select-label span').forEach(span => {
@ -278,6 +304,15 @@ NexT.utils = {
}); });
}, },
hideCommontes:function() {
document.querySelector('.post-comments').style.display = 'none';
},
hiddeLodingCmp: function(selector) {
const loadding = document.querySelector(selector).previousElementSibling;
loadding.style.display = 'none';
},
activateNavByIndex: function(index) { activateNavByIndex: function(index) {
const target = document.querySelectorAll('.post-toc li a.nav-link')[index]; const target = document.querySelectorAll('.post-toc li a.nav-link')[index];
if (!target || target.classList.contains('active-current')) return; if (!target || target.classList.contains('active-current')) return;
@ -303,13 +338,13 @@ NexT.utils = {
}, },
updateSidebarPosition: function() { updateSidebarPosition: function() {
if (window.innerWidth < 992 || CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') return; if (window.innerWidth < 992 || NexT.CONFIG.scheme === 'Pisces' || NexT.CONFIG.scheme === 'Gemini') return;
// Expand sidebar on post detail page by default, when post has a toc. // Expand sidebar on post detail page by default, when post has a toc.
const hasTOC = document.querySelector('.post-toc'); const hasTOC = document.querySelector('.post-toc');
let display = CONFIG.sidebar; let display = NexT.CONFIG.sidebar;
if (typeof display !== 'boolean') { if (typeof display !== 'boolean') {
// There's no definition sidebar in the page front-matter. // There's no definition sidebar in the page front-matter.
display = CONFIG.sidebar.display === 'always' || (CONFIG.sidebar.display === 'post' && hasTOC); display = NexT.CONFIG.sidebar.display === 'always' || (NexT.CONFIG.sidebar.display === 'post' && hasTOC);
} }
if (display) { if (display) {
window.dispatchEvent(new Event('sidebar:show')); window.dispatchEvent(new Event('sidebar:show'));
@ -344,6 +379,15 @@ NexT.utils = {
}); });
}, },
getStyle: function(src, parent) {
const link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', src);
(parent || document.head).appendChild(link);
},
getScript: function(src, options = {}, legacyCondition) { getScript: function(src, options = {}, legacyCondition) {
if (typeof options === 'function') { if (typeof options === 'function') {
return this.getScript(src, { return this.getScript(src, {
@ -362,6 +406,7 @@ NexT.utils = {
} = {}, } = {},
parentNode = null parentNode = null
} = options; } = options;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (condition) { if (condition) {
resolve(); resolve();
@ -401,7 +446,7 @@ NexT.utils = {
} }
return new Promise(resolve => { return new Promise(resolve => {
const element = document.querySelector(selector); const element = document.querySelector(selector);
if (!CONFIG.comments.lazyload || !element) { if (!element) {
resolve(); resolve();
return; return;
} }

View File

@ -1,4 +1,4 @@
# Hugo NexT theme's custom config # Hugo NexT theme's custom config
# #
version: 4.0.0 version: 4.1.0

View File

@ -1,27 +1,73 @@
# CDN 公共资源商列表
# Public CDN vendor list # Public CDN vendor list
#
vendors: vendors:
cdnjs: "//cdnjs.cloudflare.com/ajax/libs/${name}/${version}/${file}" cdnjs: "https://cdnjs.cloudflare.com/ajax/libs"
unpkg: "//unpkg.com/${name}@${version}/${file}" unpkg: "https://unpkg.com"
# JavaScript 资源
# Javascript Resources # JavaScript Resources
#
js: js:
- name: animejs - name: animejs
version: 3.2.1 version: 3.2.1
file: lib/anime.min.js file: lib/anime.min.js
- name: mathjax # TODO
version: 3.2.0 #- name: mathjax
file: es5/tex-mml-chtml.js # version: 3.2.0
# file: es5/tex-mml-chtml.js
# CSS 资源
# CSS Resources # CSS Resources
#
css: css:
- name: '@fortawesome/fontawesome-free' - name: '@fortawesome/fontawesome-free'
version: 6.1.1 version: 6.1.2
file: css/all.min.css file: css/all.min.css
alias: font-awesome alias: font-awesome
- name: animate.css - name: animate.css
version: 3.1.1 version: 3.1.1
file: animate.min.css file: animate.min.css
# 第三方服务组件资源
# 3rd servcies Resource
# 站点统计
# Site analytics engine
analytics:
la: https://sdk.51.la/js-sdk-pro.min.js
# 文章分享
# Share
addthis:
js: https://s7.addthis.com/js/300/addthis_widget.js
# 评论组件资源
# Comment component Resources
waline:
js:
name: '@waline/client'
version: 2.6.1
file: dist/waline.js
alias: waline
css:
name: '@waline/client'
version: 2.6.1
file: dist/waline.css
alias: waline
artalk:
js:
name: artalk
version: 2.3.4
file: dist/Artalk.js
css:
name: artalk
version: 2.3.4
file: dist/Artalk.css
giscus:
js: https://giscus.app/client.js
utterances:
js: https://utteranc.es/client.js
livere:
js: https://cdn-city.livere.com/js/embed.dist.js

View File

@ -86,7 +86,7 @@ menus:
weight: 2 weight: 2
- identifier: archives - identifier: archives
name: 归档 name: 归档
pageref: /posts pageref: /archives
pre: archive pre: archive
weight: 3 weight: 3
- identifier: commonweal - identifier: commonweal
@ -103,7 +103,7 @@ params:
# 需要显示文章的部分即content目录下的文件夹名称 # 需要显示文章的部分即content目录下的文件夹名称
# Sections for show in home & archive page # Sections for show in home & archive page
# and it's forlder name which under content # and it's forlder name which under content
mainSections: ["posts"] mainSections: ["post"]
# 年,月,日及时间的格式化样式 # 年,月,日及时间的格式化样式
# Format style for year,month,date & time # Format style for year,month,date & time
yearFormat: "2006" yearFormat: "2006"
@ -139,7 +139,7 @@ params:
appleTouchIcon: /imgs/icons/apple_touch_icon_next.png appleTouchIcon: /imgs/icons/apple_touch_icon_next.png
# 自定义 Logo (目前只支持 Mist 页面模式) # 自定义 Logo (目前只支持 Mist 页面模式)
# Custom Logo (Warning: Do not support scheme Mist) # Custom Logo (Warning: Only support scheme Mist)
customLogo: #/imgs/hugo_next_logo.png customLogo: #/imgs/hugo_next_logo.png
# 知识共享国际许可 4.0 # 知识共享国际许可 4.0
@ -553,7 +553,7 @@ params:
enable: true enable: true
# 你的 Github 仓库地址 # 你的 Github 仓库地址
# Your repository url on Github. # Your repository url on Github.
permalink: https://github.com/yourname permalink: https://github.com/hugo-next
# 关注说明 # 关注说明
# Show this title when cursor move on. # Show this title when cursor move on.
title: Follow me on GitHub title: Follow me on GitHub
@ -765,35 +765,35 @@ params:
# 更多配置信息请参考https://artalk.js.org # 更多配置信息请参考https://artalk.js.org
# Artalk comments system # Artalk comments system
# More info see: https://artalk.js.org # More info see: https://artalk.js.org
artalk: # artalk:
site: "默认站点" # site: "默认站点"
placeholder: "请文明发言,谢谢!" # placeholder: "请文明发言,谢谢!"
server: #<your artalk server url> # server: #<your artalk server url>
# Artalk 评论插件 # Artalk 评论插件
# 更多配置信息请参考: # 更多配置信息请参考:
# LiveRe comments system # LiveRe comments system
# You can get your uid from https://livere.com/ # You can get your uid from https://livere.com/
livere: # livere:
uid: # <your_uid> # uid: # <your_uid>
# Utterances 评论插件 # Utterances 评论插件
# 更多配置信息请参考https://utteranc.es # 更多配置信息请参考https://utteranc.es
# Utterances comments system # Utterances comments system
# For more information: https://utteranc.es # For more information: https://utteranc.es
utterances: # utterances:
# Github 仓库地址,格式:用户名/仓库名称 # # Github 仓库地址,格式:用户名/仓库名称
# Github repository owner and name # # Github repository owner and name
repo: username/repo-name # repo: username/repo-name
# 问题标题的模式可选值pathname | url | title | og:title # # 问题标题的模式可选值pathname | url | title | og:title
# Available values: pathname | url | title | og:title # # Available values: pathname | url | title | og:title
issueTerm: pathname # issueTerm: pathname
# 问题的标签分类 # # 问题的标签分类
# Label flag for Github issues # # Label flag for Github issues
label: comments # label: comments
# 主题可选值: github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-light # # 主题可选值: github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-light
# Available values: github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-light # # Available values: github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-light
theme: preferred-color-scheme # theme: preferred-color-scheme
# Giscus 评论插件 # Giscus 评论插件
# 更多配置信息请参考https://giscus.app # 更多配置信息请参考https://giscus.app
@ -802,16 +802,24 @@ params:
giscus: giscus:
# Github 仓库地址,格式:用户名/仓库名称 # Github 仓库地址,格式:用户名/仓库名称
# Github repository owner and name # Github repository owner and name
repo: username/repo_name repo: username/repo-name
# Giscus 生成的仓库 Id # Giscus 生成的仓库 Id
# Generate repository Id from Giscus # Generate repository Id from Giscus
repoId: #<repo_id> repoId: #<repo-id>
# 讨论区的分类名称 # 讨论区的分类名称
# Github discussions category # Github discussions category
category: Announcements category: Comments
# 讨论区分类 ID # 讨论区分类 ID
# Generate category Id from Giscus # Generate category Id from Giscus
categoryId: #<category_id> categoryId: #<category-id>
# 帖子上的反应将会显示在评论前
# The reactions for post will be shown before the comments
reactions: false
# 将元数据定期被发送到父页面(被嵌入的页面或控制台,用于调试)
# Metadata will be sent periodically to the parent window
emit: false
# 评论输入框的位置,可选值: top | bottom
# Aavilable value: top | bottom
# 讨论区帖子标题,可选值: pathname | url | title | og:title | 自定义 # 讨论区帖子标题,可选值: pathname | url | title | og:title | 自定义
# Available values: pathname | url | title | og:title | custom # Available values: pathname | url | title | og:title | custom
mapping: title mapping: title

View File

@ -1,19 +0,0 @@
---
title: "关于 Hugo NexT 组织"
description: ""
date: 2022-06-09T20:12:52+08:00
lastmod: 2022-06-09T20:12:52+08:00
share: false
followme: false
nav: false
copyright: false
url: about.html
---
`Hugo NexT` 组织是由众多喜爱 `NexT` 主题及风格的世界各地友人共同组建而成,为的就是让这个主题继续在 `Hugo` 引擎中也能得到发扬光大,在此也欢迎你的加入!
# 我们的愿景
延续 `NexT` 经典的黑白调搭配,保持简单的易用性及强大的功能。

View File

@ -0,0 +1,3 @@
---
date: 2022-07-26T21:46:25+08:00
---

View File

@ -20,4 +20,4 @@ EOT
next `cat ../VERSION` next `cat ../VERSION`
hugo server -D -t ../.. --port 1414 --panicOnWarning hugo server -D -t ../.. --port 1414 --panicOnWarning --config config.dev.yaml

View File

@ -1,49 +0,0 @@
#--------------------------------------
# English Version
#--------------------------------------
[ColoneFlag]
other = ":"
[SitePostsTitle]
other = "Posts"
[SiteCatesTitle]
other = "Categories"
[SiteTagsTitle]
other = "Tags"
[TableOfContents]
other = "TOC"
[SiteInfo]
other = "Site Info"
[RSSTitle]
other = "RSS Subscribe"
[CCLinkTitle]
other = "Creative Commons"
[PostPublishDate]
other = "Publish"
[PostPublishTime]
other = "Create Time"
[PostLastModDate]
other = "Update"
[PostLastModTime]
other = "Modify Time"
[PostWords]
other = "Words"
[PostWordCount]
other = "{{- .WordCount -}}"
[PostReading]
other = "Read"
[PostReadTime]
other = "{{- .ReadingTime -}}min"
[PostVisitor]
other = "Views"
[PostCatg]
other = "Categories"
[PostTag]
other = "Tags"
[PostReadMore]
other = "Read More"
[FooterPowerby]
other = "Power by %s"

View File

@ -1,7 +1,7 @@
#-------------------------------------- #--------------------------------------
# English Version # English Version
#-------------------------------------- #--------------------------------------
posts: archives:
other: Posts other: Posts
tag: tag:
other: Tag other: Tag

View File

@ -1,49 +0,0 @@
#--------------------------------------
# 中文版本
#--------------------------------------
[ColoneFlag]
other = ""
[SitePostsTitle]
other = "日志"
[SiteCatesTitle]
other = "分类"
[SiteTagsTitle]
other = "标签"
[TableOfContents]
other = "文章目录"
[SiteInfo]
other = "站点概览"
[RSSTitle]
other = "RSS 订阅"
[CCLinkTitle]
other = "共享知识"
[PostPublishDate]
other = "发表于"
[PostPublishTime]
other = "创建时间"
[PostLastModDate]
other = "更新于"
[PostLastModTime]
other = "修改时间"
[PostWords]
other = "字数"
[PostWordCount]
other = "{{- .WordCount -}}"
[PostReading]
other = "阅读"
[PostReadTime]
other = "{{- .ReadingTime -}}分钟"
[PostVisitor]
other = "浏览数"
[PostCatg]
other = "分类"
[PostTag]
other = "标签"
[PostReadMore]
other = "阅读全文"
[FooterPowerby]
other = "由 %s 强力驱动"

View File

@ -2,7 +2,7 @@
# 中文版本 # 中文版本
#-------------------------------------- #--------------------------------------
posts: archives:
other: 文章 other: 文章
tag: tag:
other: 标签 other: 标签

View File

@ -1,4 +1,6 @@
{{- partial "init.html" . -}} {{- range $k, $v := (partialCached "init.html" .) -}}
{{- $.Scratch.Set $k $v -}}
{{- end -}}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}"> <html lang="{{ .Site.LanguageCode }}">
@ -28,13 +30,13 @@
<!-- Submenu,Content,Comment --> <!-- Submenu,Content,Comment -->
{{- block "main" . }}{{- end }} {{- block "main" . }}{{- end }}
{{- if .IsPage }} {{- if .IsPage }}
{{- partial "comments.html" . }} {{- partialCached "comments.html" . }}
{{- end }} {{- end }}
</div> </div>
</main> </main>
<footer class="footer"> <footer class="footer">
<div class="footer-inner"> <div class="footer-inner">
{{- partial "footer.html" . }} {{- partialCached "footer.html" . }}
</div> </div>
</footer> </footer>

View File

@ -1,29 +1,7 @@
{{ range .Paginator.Pages.GroupByDate "2006" }} {{- if and .Page.IsSection (eq .Section "archives") }}
<div class="collection-year"> {{- $paginator := (.Paginate (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)).Pages.GroupByDate "2006" }}
<span class="collection-header">{{ .Key }}</span> {{ partial "list.html" $paginator }}
</div> {{ else }}
{{ range .Pages }} {{- $paginator := .Paginator.Pages.GroupByDate "2006" }}
<article itemscope itemtype="http://schema.org/Article"> {{ partial "list.html" $paginator }}
<header class="post-header">
<div class="post-meta-container">
{{ $month := .Date.Format .Site.Params.monthFormat }}
<time itemprop="dateCreated" datetime="{{ .Date.Format .Site.Params.timeFormat }}" content="{{ $month }}">
{{ $month }}
</time>
</div>
<div class="post-title">
{{- if isset .Params "extlink" }}
<a href="{{ .Params.extlink }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-title-link post-title-link-external" title="">
<span itemprop="name">{{- .Title -}}</span>
<i class="fa fa-external-link-alt"></i>
</a>
{{- else }}
<a class="post-title-link" href="{{ .Permalink }}" itemprop="url">
<span itemprop="name">{{ .Title }}</span>
</a>
{{- end }} {{- end }}
</div>
</header>
</article>
{{ end }}
{{ end }}

View File

@ -8,6 +8,9 @@
<div class="collection-title"> <div class="collection-title">
{{- $cheers := "Um" }} {{- $cheers := "Um" }}
{{- $posts := .Scratch.Get "postsCount" }} {{- $posts := .Scratch.Get "postsCount" }}
{{- if and .Page.IsSection (ne .Section "archives") }}
{{- $posts = .Scratch.Get .Section }}
{{- end }}
{{- if gt $posts 210 }} {{- if gt $posts 210 }}
{{- $cheers = "Excellent" }} {{- $cheers = "Excellent" }}
{{- else if gt $posts 130 }} {{- else if gt $posts 130 }}

View File

@ -1,2 +1,17 @@
<script charset="UTF-8" id="LA_COLLECT" src="https://sdk.51.la/js-sdk-pro.min.js"></script> <script type="text/javascript">
<script>LA.init({id: "{{ . }}",ck: "{{ . }}",autoTrack:true})</script> document.addEventListener('DOMContentLoaded', () => {
var script = document.createElement('script');
script.charset = "UTF-8";
script.id = "LA_COLLECT";
script.src = "{{ .Site.Data.resources.analytics.la }}";
script.async = "true"
script.onload = function() {
{{ with .Site.Params.analytics.laId }}
LA.init({ id: "{{ . }}",ck: "{{ . }}", autoTrack:true });
{{ end }}
}
document.head.appendChild(script);
});
</script>

View File

@ -1,20 +1 @@
{{- with .Site.Params.artalk }} <div class="artalk-container"></div>
<link href="//unpkg.com/artalk@2.3.4/dist/Artalk.css" rel="stylesheet">
<script src="//unpkg.com/artalk@2.3.4/dist/Artalk.js"></script>
<!-- Artalk -->
<div id="Comments"></div>
<script>
new Artalk({
el : '#Comments',
pageKey : '{{ $.Page.RelPermalink }}',
pageTitle : '{{ $.Page.Title }}',
server : '{{ .server }}',
site : '{{ .site }}',
locale : 'auto',
placeholder : '{{ .placeholder }}'
})
</script>
{{- end }}

View File

@ -1,18 +1 @@
{{- with .Site.Params.giscus }} <div class="giscus-container"></div>
<div class="giscus" style="position: relative;"></div>
<script src="https://giscus.app/client.js"
data-repo="{{ .repo }}"
data-repo-id="{{ .repoId }}"
data-category="{{ .category }}"
data-category-id="{{ .categoryId }}"
data-mapping="{{ .mapping }}"
data-reactions-enabled="0"
data-emit-metadata="1"
data-input-position="{{ .inputPosition }}"
data-theme="{{ .theme }}"
data-lang="{{ $.Site.LanguageCode }}"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
{{- end }}

View File

@ -1,13 +1 @@
{{- with .Site.Params.LiveRe }} <div id="lv-container" data-id="city" data-uid="{{ .Site.Params.livere.uid }}"></div>
<div id="lv-container" data-id="city" data-uid="{{ .uid }}"></div>
<script type="text/javascript">
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = '//cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
</script>
{{- end }}

View File

@ -1,9 +1 @@
{{- with .Site.Params.utterances }} <div class="utterances-container"></div>
<script src="https://utteranc.es/client.js"
repo="{{ .repo }}"
issue-term="{{ .issueTerm }}"
label="{{ .label }}"
crossorigin="anonymous"
theme="{{ .theme }}" async>
</script>
{{- end }}

View File

@ -1,23 +1 @@
{{- with .Site.Params.waline }} <div class="waline-container"></div>
<div id="waline"></div>
<link rel="stylesheet" href="//unpkg.com/@waline/client@v2/dist/waline.css"/>
<script src="//unpkg.com/@waline/client@v2/dist/waline.js"></script>
<script type="text/javascript">
const locale = {
placeholder: "{{ .placeholder }}"
};
Waline.init({
locale,
el : "#waline",
pageview : {{ .pageView }},
emoji : {{ .emoji }},
imageUploader : {{ .imgUploader }},
wordLimit : {{ .wordLimit }},
requiredMeta : {{ .requiredMeta }},
serverURL : "{{ .serverURL }}",
lang : "{{ $.Lang }}",
dark : "auto"
});
</script>
{{- end }}

View File

@ -1,5 +1,3 @@
{{- with .Site.Params.addThisId }} {{- if isset .Site.Params "addthisid" }}
<div class="addthis_inline_share_toolbox" style="text-align: center;"> <div class="addthis_inline_share_toolbox" style="text-align: center;"></div>
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{ . }}" async="async"></script>
</div>
{{- end }} {{- end }}

View File

@ -1,6 +1,5 @@
{{- $root := . -}} {{- $root := . -}}
{{- with .Site.Params.comments }} {{- with .Site.Params.comments }}
{{- if .enable }}
{{- $tc := and .storage (gt (len .nav) 1) }} {{- $tc := and .storage (gt (len .nav) 1) }}
{{- $active := .active }} {{- $active := .active }}
{{- $fc := .active }} {{- $fc := .active }}
@ -41,4 +40,3 @@
</div> </div>
</div> </div>
{{- end }} {{- end }}
{{- end }}

View File

@ -5,4 +5,6 @@
{{- partial "head/facebook.html" . }} {{- partial "head/facebook.html" . }}
{{- partial "head/verify.html" . }} {{- partial "head/verify.html" . }}
{{- partialCached "head/style.html" . }} {{- partialCached "head/style.html" . }}
{{- partial "head/config.html" . }}
{{- partialCached "head/analytics.html" . }} {{- partialCached "head/analytics.html" . }}

View File

@ -1,5 +1,3 @@
{{- with .Site.Params.analytics }} {{- if isset .Site.Params.analytics "laid" }}
{{- if isset . "laid" }} {{ partial "_thirdparty/analytics/51la.html" . }}
{{ partial "_thirdparty/analytics/51la.html" .laId }}
{{- end }}
{{- end }} {{- end }}

View File

@ -0,0 +1,10 @@
<script class="next-config" data-name="page" type="application/json">
{{- dict
"isHome" .IsHome
"isPage" .IsPage
"comments" (.Params.comments | default .Site.Params.comments.enable)
"permalink" (.Page.Permalink | absURL)
"path" (.Page.Permalink | path.Base)
"title" .Page.Title
-}}
</script>

View File

@ -1,7 +1,9 @@
<!-- Website icons --> <!-- Website icons -->
<link rel="shortcut icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}"> {{- with .Site.Params.favicon }}
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}"> <link rel="shortcut icon" type="image/x-icon" href="{{ .icon }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon.small }}"> <link rel="icon" type="image/x-icon" href="{{ .icon }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ .Site.Params.favicon.medium }}"> <link rel="icon" type="image/png" sizes="16x16" href="{{ .small }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ .Site.Params.favicon.appleTouchIcon }}"> <link rel="icon" type="image/png" sizes="32x32" href="{{ .medium }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ .appleTouchIcon }}">
{{- end }}
<!-- Website icons --> <!-- Website icons -->

View File

@ -1,9 +1,9 @@
<!-- Plugin style files --> <!-- Plugin style files -->
{{- $cssRes := .Site.Data.resources.css }} {{- $cssRes := .Site.Data.resources.css }}
{{- $vendor := .Site.Params.vendors.plugins }} {{- $vendor := .Site.Params.vendors.plugins }}
{{- $vendorCDN := .Scratch.Get "pluginCDN" }} {{- $router := .Scratch.Get "router" }}
{{ $cssFmt := "%s/%s@%s/%s" }}
{{- range $css := $cssRes }} {{- range $css := $cssRes }}
{{- $pluginCSS := $vendorCDN }}
{{- $npm := $css.name }} {{- $npm := $css.name }}
{{- $file := $css.file }} {{- $file := $css.file }}
{{- if eq $vendor "cdnjs" }} {{- if eq $vendor "cdnjs" }}
@ -11,12 +11,12 @@
{{- $npm = . }} {{- $npm = . }}
{{- end }} {{- end }}
{{- $file = replaceRE `(dist|lib|source\/js)\/` "" $css.file }} {{- $file = replaceRE `(dist|lib|source\/js)\/` "" $css.file }}
{{- $cssFmt = "%s/%s/%s/%s" }}
{{- end }} {{- end }}
{{- $pluginCSS = replace $pluginCSS "${name}" $npm }} {{- $pluginCSS := printf $cssFmt $router $npm $css.version $file }}
{{- $pluginCSS = replace $pluginCSS "${version}" $css.version }} <link type="text/css" rel="stylesheet" href="{{ $pluginCSS }}" />
{{- $pluginCSS = replace $pluginCSS "${file}" $file }}
<link rel="stylesheet" href="{{ $pluginCSS }}">
{{- end }} {{- end }}
<!-- Main Style file --> <!-- Main Style file -->
{{- $scss := resources.Get "css/main.scss" }} {{- $scss := resources.Get "css/main.scss" }}
{{- $scss = $scss | resources.ExecuteAsTemplate "main.scss" . }} {{- $scss = $scss | resources.ExecuteAsTemplate "main.scss" . }}

View File

@ -1,14 +1,91 @@
{{/* Use to defind global variables */}} {{/* Use to defind global variables */}}
{{- if not hugo.IsExtended }} {{ if not hugo.IsExtended }}
{{- warnf "Hugo NexT 主题使用了 SCSS 框架,请到官方地址下载 Hugo Extended 版本https://github.com/gohugoio/hugo/releases" -}} {{ warnf "Hugo NexT 主题使用了 SCSS 框架,请到官方地址下载 Hugo Extended 版本https://github.com/gohugoio/hugo/releases" }}
{{- errorf "Because that use SCSS framework in Hugo NexT, Please download Hugo extended version on offical site: https://github.com/gohugoio/hugo/releases" -}} {{ errorf "Because that use SCSS framework in Hugo NexT, Please download Hugo extended version on offical site: https://github.com/gohugoio/hugo/releases" }}
{{- end }} {{ end }}
{{- .Scratch.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) -}} {{ $version := int (index (split hugo.Version ".") 1) }}
{{- .Scratch.Set "catsCount" (len .Site.Taxonomies.categories) -}} {{ if lt $version 89 }}
{{- .Scratch.Set "tagsCount" (len .Site.Taxonomies.tags) -}} {{ warnf "当前 Hugo 版本小于 0.89.0,请到官方地址下载 Hugo 最新版本https://github.com/gohugoio/hugo/releases" }}
{{- $vendors := .Site.Data.resources.vendors -}} {{ errorf "Current Hugo version is less then 0.89.0, Please download Hugo latest version on offical site: https://github.com/gohugoio/hugo/releases" }}
{{- $pluginVen := .Site.Params.vendors.plugins -}} {{ end }}
{{- $pluginCDN := index $vendors $pluginVen -}}
{{- .Scratch.Set "pluginCDN" $pluginCDN -}} {{ $globalVars := newScratch }}
{{ $globalVars.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) }}
{{ range .Site.Params.mainSections }}
{{ $globalVars.Set . (len (where $.Page.Site.RegularPages "Section" .))}}
{{ end }}
{{ $globalVars.Set "catsCount" (len .Site.Taxonomies.categories) }}
{{ $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) }}
{{ $vendor := .Site.Params.vendors.plugins }}
{{ $router := index .Site.Data.resources.vendors $vendor }}
{{ $globalVars.Set "router" $router }}
{{ $config := dict
"hostname" .Site.BaseURL
"root" "/"
"lang" .Site.LanguageCode
"vendor" (dict "plugins" $vendor "router" $router)
"darkmode" .Site.Params.darkmode
"version" .Site.Data.config.version
"scheme" .Site.Params.scheme
"sidebar" .Site.Params.sidebar
"copybtn" .Site.Params.codeblock.copyBtn
"bookmark" .Site.Params.bookmark
"lazyload" .Site.Params.lazyload
"motion" .Site.Params.motion
}}
{{ with .Site.Params.waline }}
{{ $waline := dict
"js" $.Site.Data.resources.waline.js
"css" $.Site.Data.resources.waline.css
"cfg" .
}}
{{ $config = merge $config (dict "waline" $waline) }}
{{ end }}
{{ with .Site.Params.giscus }}
{{ $giscus := dict
"js" $.Site.Data.resources.giscus.js
"cfg" .
}}
{{ $config = merge $config (dict "giscus" $giscus) }}
{{ end }}
{{ with .Site.Params.artalk }}
{{ $artalk := dict
"js" $.Site.Data.resources.artalk.js
"css" $.Site.Data.resources.artalk.css
"cfg" .
}}
{{ $config = merge $config (dict "artalk" $artalk) }}
{{ end }}
{{ with .Site.Params.livere }}
{{ $livere := dict "js" $.Site.Data.resources.livere.js }}
{{ $config = merge $config (dict "livere" $livere) }}
{{ end }}
{{ with .Site.Params.utterances }}
{{ $utterances := dict
"js" $.Site.Data.resources.utterances.js
"cfg" .
}}
{{ $config = merge $config (dict "utterances" $utterances) }}
{{ end }}
{{ with .Site.Params.addThisId }}
{{ $addthis := dict
"js" $.Site.Data.resources.addthis.js
"cfg" (dict "pubid" .)
}}
{{ $config = merge $config (dict "addthis" $addthis) }}
{{ end }}
{{ $globalVars.Set "config" $config }}
{{ return $globalVars.Values }}

View File

@ -0,0 +1,29 @@
{{ range . }}
<div class="collection-year">
<span class="collection-header">{{ .Key }}</span>
</div>
{{ range .Pages }}
<article itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<div class="post-meta-container">
{{ $month := .Date.Format "01-02" }}
<time itemprop="dateCreated" datetime="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}" content="{{ $month }}">
{{ $month }}
</time>
</div>
<div class="post-title">
{{- if isset .Params "extlink" }}
<a href="{{ .Params.extlink }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-title-link post-title-link-external" title="">
<span itemprop="name">{{- .Title -}}</span>
<i class="fa fa-external-link-alt"></i>
</a>
{{- else }}
<a class="post-title-link" href="{{ .Permalink }}" itemprop="url">
<span itemprop="name">{{ .Title }}</span>
</a>
{{- end }}
</div>
</header>
</article>
{{ end }}
{{ end }}

View File

@ -1,9 +1,9 @@
<!-- Plugin scripts files --> <!-- Plugin scripts files -->
{{- $jsRes := .Site.Data.resources.js }} {{- $jsRes := .Site.Data.resources.js }}
{{- $vendor := .Site.Params.vendors.plugins }} {{- $vendor := .Site.Params.vendors.plugins }}
{{- $vendorCDN := .Scratch.Get "pluginCDN" }} {{- $router := .Scratch.Get "router" }}
{{ $jsFmt := "%s/%s@%s/%s" }}
{{- range $js := $jsRes }} {{- range $js := $jsRes }}
{{- $pluginJS := $vendorCDN }}
{{- $npm := $js.name }} {{- $npm := $js.name }}
{{- $file := $js.file }} {{- $file := $js.file }}
{{- if eq $vendor "cdnjs" }} {{- if eq $vendor "cdnjs" }}
@ -11,14 +11,15 @@
{{- $npm = . }} {{- $npm = . }}
{{- end }} {{- end }}
{{- $file = replaceRE `(dist|lib|source\/js)\/` "" $js.file }} {{- $file = replaceRE `(dist|lib|source\/js)\/` "" $js.file }}
{{- $jsFmt = "%s/%s/%s/%s" }}
{{- end }} {{- end }}
{{- $pluginJS = replace $pluginJS "${name}" $npm }} {{- $pluginJS := printf $jsFmt $router $npm $js.version $file }}
{{- $pluginJS = replace $pluginJS "${version}" $js.version }}
{{- $pluginJS = replace $pluginJS "${file}" $file }}
<script type="text/javascript" src="{{ $pluginJS }}" defer></script> <script type="text/javascript" src="{{ $pluginJS }}" defer></script>
{{- end }} {{- end }}
{{- $config := resources.Get "js/config.js" | resources.ExecuteAsTemplate "config.js" . }} <script class="next-config" data-name="main" type="application/json">{{- .Scratch.Get "config" -}}</script>
{{- $config := resources.Get "js/config.js" }}
{{- $motion := resources.Get "js/motion.js" }} {{- $motion := resources.Get "js/motion.js" }}
{{- $boot := resources.Get "js/next-boot.js" }} {{- $boot := resources.Get "js/next-boot.js" }}
{{- $utils := resources.Get "js/utils.js" }} {{- $utils := resources.Get "js/utils.js" }}
@ -39,7 +40,31 @@
{{- $pjaxjs := resources.Get "js/pjax.js" }} {{- $pjaxjs := resources.Get "js/pjax.js" }}
{{- $nextjs = $nextjs | append $pjaxjs }} {{- $nextjs = $nextjs | append $pjaxjs }}
{{- end }} {{- end }}
{{- $nextjs = $nextjs | resources.Concat "js/hugo-next.js"}} {{- if isset .Site.Params "addthisid" }}
{{- $addthisjs := resources.Get "js/third-party/share/addthis.js" }}
{{- $nextjs = $nextjs | append $addthisjs }}
{{- end }}
{{- if isset .Site.Params "waline" }}
{{- $walinejs := resources.Get "js/third-party/comments/waline.js" }}
{{- $nextjs = $nextjs | append $walinejs }}
{{- end }}
{{- if isset .Site.Params "giscus" }}
{{- $giscusjs := resources.Get "js/third-party/comments/giscus.js" }}
{{- $nextjs = $nextjs | append $giscusjs }}
{{- end }}
{{- if isset .Site.Params "livere" }}
{{- $liverejs := resources.Get "js/third-party/comments/livere.js" }}
{{- $nextjs = $nextjs | append $liverejs }}
{{- end }}
{{- if isset .Site.Params "artalk" }}
{{- $artalkjs := resources.Get "js/third-party/comments/artalk.js" }}
{{- $nextjs = $nextjs | append $artalkjs }}
{{- end }}
{{- if isset .Site.Params "utterances" }}
{{- $utterancesjs := resources.Get "js/third-party/comments/utterances.js" }}
{{- $nextjs = $nextjs | append $utterancesjs }}
{{- end }}
{{- $nextjs = $nextjs | resources.Concat "js/main.js"}}
{{ if hugo.IsProduction }} {{ if hugo.IsProduction }}
{{- $nextjs = $nextjs | minify | fingerprint }} {{- $nextjs = $nextjs | minify | fingerprint }}
{{ end }} {{ end }}