refactor(pages): use html instead of json to render legal
This commit is contained in:
parent
f98647cabb
commit
2d74d8afc3
4 changed files with 18 additions and 45 deletions
21
data.go
21
data.go
|
@ -34,7 +34,7 @@ type Config struct {
|
|||
Person *Person `json:"person" toml:"person"`
|
||||
Color *Color `json:"colors" toml:"colors"`
|
||||
Links []*Link `json:"links" toml:"links"`
|
||||
Legal *Legal `json:"legal" toml:"legal"`
|
||||
Legal string `json:"legal" toml:"legal"`
|
||||
CustomPages []string `json:"custom_pages" toml:"custom_pages"`
|
||||
}
|
||||
|
||||
|
@ -79,12 +79,6 @@ type Link struct {
|
|||
Content string `json:"content" toml:"content"`
|
||||
}
|
||||
|
||||
type Legal struct {
|
||||
LegalInformationLink string `json:"legal_information_link" toml:"legal_information_link"`
|
||||
ImagesSource []string `json:"images_source" toml:"images_source"`
|
||||
FontSource string `json:"font_source" toml:"font_source"`
|
||||
}
|
||||
|
||||
func (c *Config) GetBackground() template.CSS {
|
||||
return c.Color.GetBackground()
|
||||
}
|
||||
|
@ -142,6 +136,19 @@ func (c *Config) LoadCustomPages() ([]*CustomPage, error) {
|
|||
return pages, nil
|
||||
}
|
||||
|
||||
var legalContent template.HTML
|
||||
|
||||
func (c *Config) GetLegal() (template.HTML, error) {
|
||||
if legalContent == "" {
|
||||
b, err := os.ReadFile(c.Legal)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
legalContent = template.HTML(b)
|
||||
}
|
||||
return legalContent, nil
|
||||
}
|
||||
|
||||
func (t *Color) GetTextColor() template.CSS {
|
||||
return template.CSS("--text-color: " + t.Text + ";")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue