diff --git a/assets/js/next-boot.js b/assets/js/next-boot.js index 4de12ab..a37e40e 100644 --- a/assets/js/next-boot.js +++ b/assets/js/next-boot.js @@ -44,14 +44,15 @@ NexT.boot.refresh = function() { CONFIG.lazyload && window.lozad('.post-body img').observe(); CONFIG.pangu && window.pangu.spacingPage(); - NexT.utils.registerCopyCode(); + CONFIG.isPage && NexT.utils.replacePostCRLink(); + CONFIG.isPage && NexT.utils.registerCopyCode(); NexT.utils.registerTabsTag(); /*NexT.utils.registerActiveMenuItem(); NexT.utils.registerLangSelect();*/ - NexT.utils.registerSidebarTOC(); - NexT.utils.registerPostReward(); - NexT.utils.initCommontesDispaly(); - NexT.utils.registerCommonSwitch(); + CONFIG.isPage && NexT.utils.registerSidebarTOC(); + CONFIG.isPage && NexT.utils.registerPostReward(); + CONFIG.isPage && NexT.utils.initCommontesDispaly(); + CONFIG.isPage && NexT.utils.registerCommonSwitch(); NexT.utils.wrapTableWithBox(); NexT.utils.registerVideoIframe(); }; diff --git a/assets/js/utils.js b/assets/js/utils.js index b71651e..e014822 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -23,6 +23,19 @@ HTMLElement.prototype.wrap = function(wrapper) { NexT.utils = { + replacePostCRLink: function() { + if (CONFIG.hostname.startsWith('http')) return; + // Try to support mutli domain without base URL sets. + let href = window.location.href; + if (href.indexOf('#')>-1){ + href = href.split('#')[0]; + } + let postLink = document.getElementById('post-cr-link'); + if (!postLink) return; + postLink.text = href; + postLink.href = href; + }, + /** * One-click copy code support. */ diff --git a/layouts/partials/post/footer_meta/copyright.html b/layouts/partials/post/footer_meta/copyright.html index edc35bf..0a9eb53 100644 --- a/layouts/partials/post/footer_meta/copyright.html +++ b/layouts/partials/post/footer_meta/copyright.html @@ -21,7 +21,7 @@ {{ .Params.Link }} {{- else }} {{ print (T "PostCRLink") (T "SymbolColon") }} - {{ .Permalink | absLangURL }} + {{ .Permalink | absLangURL }} {{- end }}