1

我正在为我的网站构建一个小型图片库,并希望它按创建日期排序。图库是作为页面包构建的,其中单个图像存储在子文件夹中。有什么方法可以从模板中访问文件的创建日期,就像您使用.Date.Lastmod用于帖子一样?

我正在寻找不需要在文件名中编码日期或为前面的每个图像设置参数的解决方案。

<!--                              need something here 
                                           |                     -->
{{ range sort (.Resources.ByType "image") [?] "desc"}}
  {{ $image := .Fill "500x500 center" }}
  {{ $imageName := replace (path.Base .Name) (path.Ext .Name) ""}}
  <li>
    <figure>
      <a href="{{.RelPermalink}}">
        <img src="{{$image.RelPermalink}}" alt="{{$imageName}}" width="{{$image.Width}}px" height="{{$image.Height}}px"/>
      </a>
      <figcaption>{{$imageName}}</figcaption>
    </figure>
  </li>
{{ end }}
4

0 回答 0