diff --git a/layouts/_default/search.json b/layouts/_default/search.json index f740da8..b374521 100644 --- a/layouts/_default/search.json +++ b/layouts/_default/search.json @@ -4,6 +4,14 @@ {{ $mscratch.Add "articles" slice }} {{ $pages := where .Site.RegularPages "Params.nosearch" "!=" "true" }} {{ range $pages }} + {{ $image := "" }} + {{ if .Params.Image }} + {{ if or (hasPrefix .Params.Image "/") (hasPrefix .Params.Image "http://") (hasPrefix .Params.Image "https://") }} + {{ $image = .Params.Image }} + {{ else }} + {{ $image = path.Join "/" (path.Join .File.Dir .Params.Image) }} + {{ end }} + {{ end }} {{ $mscratch.Add "articles" (dict "title" .Title "date" (.Date.Format "2006-01-02") @@ -11,7 +19,7 @@ "summary" (or .Params.description .Summary) "text" (lower .Plain) "link" .Permalink - "image" (or .Params.Image "")) }} + "image" $image) }} {{ end }} "pages": {{ $mscratch.Get "articles" | jsonify }} } diff --git a/layouts/index.json b/layouts/index.json index 4259ba0..1d17dd4 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -11,13 +11,21 @@ {{ $mscratch := newScratch }} {{ $mscratch.Add "articles" slice }} {{ range (.Paginate $postsList).Pages }} + {{ $image := "" }} + {{ if .Params.Image }} + {{ if or (hasPrefix .Params.Image "/") (hasPrefix .Params.Image "http://") (hasPrefix .Params.Image "https://") }} + {{ $image = .Params.Image }} + {{ else }} + {{ $image = path.Join (path.Join .File.Dir .Params.Image) }} + {{ end }} + {{ end }} {{ $mscratch.Add "articles" (dict "title" .Title "date" (.Date.Format "2006-01-02") "tags" (sort (or .Params.tags slice)) "summary" (or .Params.description .Summary) "link" .Permalink - "image" (or .Params.Image "")) }} + "image" $image) }} {{ end }} "articles": {{ $mscratch.Get "articles" | jsonify }}, "test": "{{range $postsList}}{{.Title}} {{end}}", diff --git a/layouts/partials/article_card.html b/layouts/partials/article_card.html index 6a8c7ad..62c11bf 100644 --- a/layouts/partials/article_card.html +++ b/layouts/partials/article_card.html @@ -17,7 +17,11 @@ {{ if .Site.Params.imageInArticlePreview }} {{ if .Params.Image }} - + {{ if or (hasPrefix .Params.Image "/") (hasPrefix .Params.Image "http://") (hasPrefix .Params.Image "https://") }} + + {{ else }} + + {{ end }} {{ end }} {{end}} diff --git a/layouts/partials/featured_articles.html b/layouts/partials/featured_articles.html index 4dfdf2d..4ff6a8f 100644 --- a/layouts/partials/featured_articles.html +++ b/layouts/partials/featured_articles.html @@ -1,5 +1,13 @@