Skip to content

Commit

Permalink
feat: support local img in news section
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirrito-k423 committed Jan 21, 2024
1 parent d6e284b commit 6a2c3b8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion exampleSite/content/news/award/231227-highContribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Professor An Hong was elected as a high-contributing scholar in Chinese computer field in 2023."
types: "AWARD"
date: 2023-12-27
img_url: "/images/news/anhong.png"
img_url: "./images/news/anhong.png"
selectedInFirstPage: #
abstract: "校友会2023年中国高贡献学者榜单发布,其中计算机领域共有168人当选, 安虹教授当选"
Journalist:
Expand Down
48 changes: 44 additions & 4 deletions layouts/news/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ <h2 class="section-title">Lab News</h2>
<article class="first-grid">
<div class = "first-grid-pic">
<a href="{{ .RelPermalink }}">
<img class="landscape" src="{{ .Params.img_url }}">
{{ $img := .Params.img_url }}
{{ if strings.HasPrefix $img "http://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else if strings.HasPrefix $img "https://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else -}}
<!-- 内链图片 -->
<img class="landscape" src="{{ $.Site.BaseURL }}/{{ $img }}">
{{ end }}
</a>
</div>
<div class="grid-content">
Expand All @@ -40,7 +50,17 @@ <h3>
<article class="second-grid">
<div class = "second-grid-pic">
<a href="{{ .RelPermalink }}">
<img class="landscape" src="{{ .Params.img_url }}">
{{ $img := .Params.img_url }}
{{ if strings.HasPrefix $img "http://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else if strings.HasPrefix $img "https://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else -}}
<!-- 内链图片 -->
<img class="landscape" src="{{ $.Site.BaseURL }}/{{ $img }}">
{{ end }}
</a>
</div>
<div class="grid-content">
Expand All @@ -64,7 +84,17 @@ <h3>
<article class="second-grid">
<div class = "second-grid-pic">
<a href="{{ .RelPermalink }}">
<img class="landscape" src="{{ .Params.img_url }}">
{{ $img := .Params.img_url }}
{{ if strings.HasPrefix $img "http://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else if strings.HasPrefix $img "https://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else -}}
<!-- 内链图片 -->
<img class="landscape" src="{{ $.Site.BaseURL }}/{{ $img }}">
{{ end }}
</a>
</div>
<div class="grid-content">
Expand All @@ -90,7 +120,17 @@ <h3>
<article class="small-grid">
<div class = "small-grid-pic">
<a href="{{ .RelPermalink }}">
<img class="landscape" src="{{ .Params.img_url }}">
{{ $img := .Params.img_url }}
{{ if strings.HasPrefix $img "http://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else if strings.HasPrefix $img "https://" -}}
<!-- 外链图片 -->
<img class="landscape" src="{{ $img }}">
{{ else -}}
<!-- 内链图片 -->
<img class="landscape" src="{{ $.Site.BaseURL }}/{{ $img }}">
{{ end }}
</a>
</div>
<div class="small-grid-content">
Expand Down

0 comments on commit 6a2c3b8

Please sign in to comment.