Skip to content

Commit

Permalink
Allow to customize website cover
Browse files Browse the repository at this point in the history
  • Loading branch information
creekorful committed Sep 5, 2021
1 parent c11ec7a commit 23b6225
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ the static website will be copied and `-config-file` is the path to the configur
```yaml
title: "go-gallery"
url: https://photos.example.org
#cover_url: https://example.org/cover.png <- override the default cover
bg_color: "#1b1c1d"
font_color: "white"
border: "3px"
Expand Down
1 change: 1 addition & 0 deletions config.yaml.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
title: "go-gallery"
url: https://photos.example.org
#cover_url: https://example.org/cover.png <- override the default cover
bg_color: "#1b1c1d"
font_color: "white"
border: "3px"
Expand Down
1 change: 1 addition & 0 deletions gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
type config struct {
Title string `yaml:"title"`
URL string `yaml:"url"`
CoverURL string `yaml:"cover_url"`
BgColor string `yaml:"bg_color"`
FontColor string `yaml:"font_color"`
Border string `yaml:"border"`
Expand Down
10 changes: 7 additions & 3 deletions res/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

<meta property="og:title" content="{{ .Config.Title }}"/>
<meta property="og:type" content="website"/>
<!-- TODO: allow to configure the website cover -->
<meta property="og:image"
content="{{ .Config.URL }}/{{ (index .Albums 0).Folder }}/{{ (index (index .Albums 0).Photos 0).ThumbnailPath }}"/>

{{ if .Config.CoverURL }}
<meta property="og:image" content="{{ .Config.CoverURL }}"/>
{{ else }}
<meta property="og:image"
content="{{ .Config.URL }}/{{ (index .Albums 0).Folder }}/{{ (index (index .Albums 0).Photos 0).ThumbnailPath }}"/>
{{ end }}
</head>
<body>
<section id="albums">
Expand Down

0 comments on commit 23b6225

Please sign in to comment.