Bläddra i källkod

projects: Open external link in new tab

George Cushen 8 år sedan
förälder
incheckning
a741bc6db8
2 ändrade filer med 6 tillägg och 3 borttagningar
  1. 5 2
      layouts/partials/widgets/projects.html
  2. 1 1
      layouts/project/single.html

+ 5 - 2
layouts/partials/widgets/projects.html

@@ -33,7 +33,7 @@
           {{ if .Content }}
           <a href="{{ .Permalink }}">
           {{ else }}
-            {{ with .Params.external_link }}<a href="{{ . }}">{{ end }}
+            {{ with .Params.external_link }}<a href="{{ . }}" target="_blank">{{ end }}
           {{ end }}
           <i class="fa-li fa fa-files-o pub-icon" aria-hidden="true"></i>
           {{ .Title }}
@@ -52,13 +52,16 @@
 
       {{ range $project := where $.Data.Pages "Type" "project" }}
       {{ $.Scratch.Set "project_url" $project.Permalink }}
+      {{ $.Scratch.Set "target" "" }}
       {{ if $project.Params.external_link }}
       {{   $.Scratch.Set "project_url" $project.Params.external_link }}
+      {{   $.Scratch.Set "target" "target=\"_blank\"" }}
       {{ end }}
       <div class="col-xs-12 col-sm-6 col-md-4 col-lg-6 project-item isotope-item {{ delimit .Params.tags " " }}">
         <div class="card">
           {{ with $project.Params.image_preview }}
-          <a href="{{ $.Scratch.Get "project_url" }}" title="" class="card-image hover-overlay">
+          <a href="{{ $.Scratch.Get "project_url" }}" title="" class="card-image hover-overlay"
+             {{ $.Scratch.Get "target" | safeHTMLAttr }}>
             <img src="{{ "/img/" | relURL }}{{ . }}" alt="" class="img-responsive">
           </a>
           {{ end }}

+ 1 - 1
layouts/project/single.html

@@ -10,7 +10,7 @@
     <h1 itemprop="name">{{ .Title }}</h1>
 
     {{ with .Params.external_link }}
-    <a class="btn btn-primary btn-outline" href="{{ . }}">{{ i18n "open_project_site" }}</a>
+    <a class="btn btn-primary btn-outline" href="{{ . }}" target="_blank">{{ i18n "open_project_site" }}</a>
     {{ end }}
 
     <div class="article-style" itemprop="articleBody">