photo list

This commit is contained in:
Niko Abeler 2023-06-18 19:40:35 +02:00
parent 98e9a3b9d2
commit 10e0bde07b
4 changed files with 40 additions and 4 deletions

View File

@ -66,6 +66,25 @@
}
hgroup h2 a { color: inherit; }
.photo-grid {
display: flex;
flex-wrap: wrap;
padding: 0 4px;
}
.photo-grid-item {
flex: 1 0 25%;
padding: 4px;
}
.photo-grid-item img {
width: 100%;
height: 100%;
aspect-ratio: 1 / 1 ;
object-fit: cover;
}
</style>
</head>

View File

@ -0,0 +1,9 @@
<div class="h-feed photo-grid">
{{range .}}
<div class="h-entry photo-grid-item">
<a class="u-url" href="{{.UrlPath}}">
<img class="u-photo" src="{{.UrlPath}}media/{{.Meta.PhotoPath}}" alt="{{.Meta.Description}}" />
</a>
</div>
{{end}}
</div>

View File

@ -163,7 +163,14 @@ func RenderIndexPage(user User) (string, error) {
func RenderPostList(user User, list *PostList) (string, error) {
posts, _ := user.GetPostsOfList(*list)
postHtml, err := renderEmbedTemplate("embed/post-list.html", posts)
var postHtml string
var err error
if list.ListType == "photo" {
postHtml, err = renderEmbedTemplate("embed/post-list-photo.html", posts)
} else {
postHtml, err = renderEmbedTemplate("embed/post-list.html", posts)
}
if err != nil {
return "", err
}

View File

@ -33,9 +33,10 @@ type UserConfig struct {
}
type PostList struct {
Id string `yaml:"id"`
Title string `yaml:"title"`
Include []string `yaml:"include"`
Id string `yaml:"id"`
Title string `yaml:"title"`
Include []string `yaml:"include"`
ListType string `yaml:"list_type"`
}
type MenuItem struct {