diff options
Diffstat (limited to 'internal/web/theme.go')
| -rw-r--r-- | internal/web/theme.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/internal/web/theme.go b/internal/web/theme.go index a43603b..ee3ef11 100644 --- a/internal/web/theme.go +++ b/internal/web/theme.go @@ -576,13 +576,13 @@ var themeCSS = template.Must(template.New("theme").Funcs(template.FuncMap{"sub": @font-face { font-family:"Fira Code"; src:url(/static/FiraCode-VF.woff2) format("woff2"); font-weight:300 700; font-display:swap; } {{- end}} {{- if .CustomFont}} -@font-face { font-family:"BlogFont"; src:url(/media/{{.CustomFont}}); font-display:swap; } +@font-face { font-family:"BlogFont"; src:url({{.Media}}/{{.CustomFont}}); font-display:swap; } {{- end}} {{- if .CustomHeadingFont}} -@font-face { font-family:"BlogHeadingFont"; src:url(/media/{{.CustomHeadingFont}}); font-display:swap; } +@font-face { font-family:"BlogHeadingFont"; src:url({{.Media}}/{{.CustomHeadingFont}}); font-display:swap; } {{- end}} body { margin:0; background-color:{{.BgColor}}; color:{{.TextColor}}; font-family:{{.FontFamily}}; font-size:{{.FontSizePx}}; line-height:1.5; -{{- if .BgImage}} background-image:url(/media/{{.BgImage}}); +{{- if .BgImage}} background-image:url({{.Media}}/{{.BgImage}}); {{- if eq .BgMode "cover"}} background-size:cover; background-position:center top; background-repeat:no-repeat; {{- else if eq .BgMode "fixed"}} background-size:cover; background-position:center; background-attachment:fixed; background-repeat:no-repeat; {{- else}} background-repeat:repeat;{{end}} @@ -636,8 +636,15 @@ a:hover {{"{"}}{{if .LinkHover}} color:{{.LinkHover}};{{end}}{{if eq .LinkUnderl `)) // CSS renders the per-blog stylesheet; all values were normalized so it is safe to inline. -func (t Theme) CSS() string { +func (t Theme) CSS() string { return t.CSSAt("/media") } + +// CSSAt is CSS with the blog's files under another path: the design page's +// preview is on the root host, where /media is the root blog's. +func (t Theme) CSSAt(media string) string { var b bytes.Buffer - _ = themeCSS.Execute(&b, t) + _ = themeCSS.Execute(&b, struct { + Theme + Media string + }{t, media}) return b.String() } |
