From f155ded3e003840b3f42d1cd3008f5a8d54dfa4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Sun, 19 Jun 2022 14:53:12 +0800 Subject: [PATCH] :lipstick: Add extend URL display style. --- assets/js/config.js | 1 - assets/js/next-boot.js | 2 +- assets/js/utils.js | 16 ---------------- exampleSite/config.yaml | 6 ++++-- exampleSite/start.sh | 2 +- layouts/_default/_markup/render-link.html | 7 +++++++ 6 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 layouts/_default/_markup/render-link.html diff --git a/assets/js/config.js b/assets/js/config.js index be94ae9..992939b 100644 --- a/assets/js/config.js +++ b/assets/js/config.js @@ -9,7 +9,6 @@ if (!window.NexT) window.NexT = {}; "scheme" : "{{ .Site.Params.scheme }}", "darkmode" : {{ .Site.Params.darkmode }}, "version" : "{{ .Site.Data.config.version }}", - "exturl" : {{ .Site.Params.exturl }}, "sidebar" : {{ .Site.Params.sidebar | jsonify }}, "copycode" : {{ .Site.Params.codeblock.copyBtn | jsonify }}, "bookmark" : {{ .Site.Params.bookmark | jsonify }}, diff --git a/assets/js/next-boot.js b/assets/js/next-boot.js index dedb54b..088ccfe 100644 --- a/assets/js/next-boot.js +++ b/assets/js/next-boot.js @@ -37,7 +37,7 @@ NexT.boot.refresh = function() { * Register JS handlers by condition option. * Need to add config option in Front-End at 'scripts/helpers/next-config.js' file. */ - CONFIG.prism && window.Prism.highlightAll(); + //CONFIG.prism && window.Prism.highlightAll(); /*CONFIG.mediumzoom && window.mediumZoom('.post-body :not(a) > img, .post-body > img', { background: 'var(--content-bg-color)' });*/ diff --git a/assets/js/utils.js b/assets/js/utils.js index 62acfce..7c18011 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -23,22 +23,6 @@ HTMLElement.prototype.wrap = function(wrapper) { NexT.utils = { - registerExtURL: function() { - document.querySelectorAll('span.exturl').forEach(element => { - const link = document.createElement('a'); - // https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings - link.href = decodeURIComponent(atob(element.dataset.url).split('').map(c => { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }).join('')); - link.rel = 'noopener external nofollow noreferrer'; - link.target = '_blank'; - link.className = element.className; - link.title = element.title; - link.innerHTML = element.innerHTML; - element.parentNode.replaceChild(link, element); - }); - }, - /** * One-click copy code support. */ diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 077ce67..44a6f4c 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -608,9 +608,11 @@ params: index_with_subtitle: false # Automatically add external URL with Base64 encrypt & decrypt. - exturl: false + exturl: + enable: true + icon: true # If true, an icon will be attached to each external URL - exturl_icon: true + #exturl_icon: true # Google Webmaster tools verification. # See: https://developers.google.com/search diff --git a/exampleSite/start.sh b/exampleSite/start.sh index 165aa03..806fa5f 100644 --- a/exampleSite/start.sh +++ b/exampleSite/start.sh @@ -17,6 +17,6 @@ Documentation: https://hugo-next.js.org EOT } -next V0.0.1 +next `cat ../VERSION` hugo server -D -t ../.. --port 1414 --panicOnWarning \ No newline at end of file diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html new file mode 100644 index 0000000..8b66301 --- /dev/null +++ b/layouts/_default/_markup/render-link.html @@ -0,0 +1,7 @@ +{{- $extURL := .Page.Site.Params.exturl.enable }} + + {{ .Text | safeHTML }} + {{- if and $extURL .Page.Site.Params.exturl.icon }} + + {{- end }} + \ No newline at end of file