// Copyright (C) 2022 Marius Schellenberger

package srv

import (
	"embed"
	"html/template"
	"io/fs"
)

//go:embed templates/*
var templates embed.FS

func subMust(fsys fs.FS, dir string) fs.FS {
	fsys, err := fs.Sub(fsys, dir)
	if err != nil {
		panic("sub: " + err.Error())
	}
	return fsys
}

var tsub = subMust(templates, "templates")

var (
	index = template.Must(template.ParseFS(tsub,
		"head.html",
		"index.html",
	))
	preloads = template.Must(template.ParseFS(tsub,
		"head.html",
		"preloads.html",
	))
	cache = template.Must(template.ParseFS(tsub,
		"head.html",
		"cache.html",
	))
	video = template.Must(template.ParseFS(tsub,
		"video.html",
	))
)
