Ver código fonte

feat(profile): support [[params.social]] links to homepage sections

Enables using email icon to link to contact form.

Close #754
George Cushen 6 anos atrás
pai
commit
fa5de9234d

+ 3 - 3
exampleSite/config.toml

@@ -247,12 +247,12 @@ enableGitInfo = false
   [[params.social]]
     icon = "envelope"
     icon_pack = "fas"
-    link = "mailto:test@example.org"
+    link = "#contact"  # For a direct email link, use "mailto:test@example.org".
 
   [[params.social]]
     icon = "twitter"
     icon_pack = "fab"
-    link = "//twitter.com/GeorgeCushen"
+    link = "https://twitter.com/GeorgeCushen"
 
   [[params.social]]
     icon = "google-scholar"
@@ -262,7 +262,7 @@ enableGitInfo = false
   [[params.social]]
     icon = "github"
     icon_pack = "fab"
-    link = "//github.com/gcushen"
+    link = "https://github.com/gcushen"
 
   # Link to a PDF of your resume/CV from the About widget.
   # To enable, copy your resume/CV to `static/files/cv.pdf` and uncomment the lines below.

+ 6 - 2
layouts/partials/page_author.html

@@ -22,10 +22,14 @@
       {{ $pack := or .icon_pack "fas" }}
       {{ $pack_prefix := $pack }}
       {{ if in (slice "fab" "fas" "far" "fal") $pack }}
-      {{ $pack_prefix = "fa" }}
+        {{ $pack_prefix = "fa" }}
+      {{ end }}
+      {{ $target := "target=\"_blank\" rel=\"noopener\"" }}
+      {{ if not (urls.Parse .link).Scheme }}
+        {{ $target = "" }}
       {{ end }}
       <li>
-        <a itemprop="sameAs" href="{{ .link | safeURL }}" target="_blank" rel="noopener">
+        <a itemprop="sameAs" href="{{ .link | relLangURL | safeURL }}" {{ $target | safeHTMLAttr }}>
           <i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}"></i>
         </a>
       </li>

+ 5 - 1
layouts/partials/widgets/about.html

@@ -43,8 +43,12 @@
         {{ if in (slice "fab" "fas" "far" "fal") $pack }}
           {{ $pack_prefix = "fa" }}
         {{ end }}
+        {{ $target := "target=\"_blank\" rel=\"noopener\"" }}
+          {{ if not (urls.Parse .link).Scheme }}
+        {{ $target = "" }}
+        {{ end }}
         <li>
-          <a itemprop="sameAs" href="{{ .link | safeURL }}" target="_blank" rel="noopener">
+          <a itemprop="sameAs" href="{{ .link | relLangURL | safeURL }}" {{ $target | safeHTMLAttr }}>
             <i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} big-icon"></i>
           </a>
         </li>