Reutilizar template de mostrar NFT y mostrar nombres en index
Some checks failed
continuous-integration/woodpecker the build failed

This commit is contained in:
Cat /dev/Nulo 2021-11-10 10:43:06 -03:00
parent 5b6cf19548
commit 551fcee088
3 changed files with 12 additions and 9 deletions

View file

@ -160,9 +160,9 @@ func must(err error) {
}
func main() {
indexTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/index.tmpl")
indexTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/embed-nft.tmpl", "./templates/index.tmpl")
must(err)
nftsTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/nft.tmpl")
nftsTmpl, err := template.ParseFiles("./templates/base.tmpl", "./templates/embed-nft.tmpl", "./templates/nft.tmpl")
must(err)
http.Handle("/static/nfts/", http.StripPrefix("/static/nfts/", http.FileServer(http.Dir(NFTS_DIR))))

7
templates/embed-nft.tmpl Normal file
View file

@ -0,0 +1,7 @@
{{define "embed-nft"}}
{{if .IsVideo}}
<video controls loop src="/static/nfts/{{.FileName}}"></video>
{{else}}
<img src="/static/nfts/{{.FileName}}">
{{end}}
{{end}}

View file

@ -10,14 +10,10 @@
<h2>Algunos NFTs descargados</h2>
{{range .NFTs}}
<figure>
<a href="/nfts/{{.Id}}">
{{if .IsVideo}}
<video controls loop src="/static/nfts/{{.FileName}}"></video>
{{else}}
<img src="/static/nfts/{{.FileName}}">
{{end}}
</a>
<h3><a href="/nfts/{{.Id}}">{{.Asset.Name}}</a></h3>
{{template "embed-nft" .}}
</figure>
<hr>
{{end}}
</section>
{{end}}