1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| {% import ( "{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/util" "{{{ .Package }}}/assets" ) %}
{% func Head(as *app.State, ps *cutil.PageState) %} {%- code thm := as.Themes.Get(ps.Profile.Theme, ps.Logger) -%} <meta charset="UTF-8"> <title>{%s ps.TitleString() %}</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"> {% if ps.Description != "" %}<meta property="description" content="{%s ps.Description %}"> {% endif %}<meta property="og:title" content="{%s ps.TitleString() %}"> <meta property="og:type" content="website"> <meta property="og:image" content="/assets/{%u util.AppKey %}.svg"> <meta property="og:locale" content="en_US"> <meta name="theme-color" content="{%s thm.Light.NavBackground %}" media="(prefers-color-scheme: light)"> <meta name="theme-color" content="{%s thm.Dark.NavBackground %}" media="(prefers-color-scheme: dark)">{%s= ps.HeaderContent %} <link rel="icon" href="{%s assets.URL(`logo.svg`) %}" type="image/svg+xml"> {% if !ps.NoStyle %} <style> {%s= thm.CSS(2) %} </style>{% endif %}{%- if ps.HideHeader && ps.HideMenu -%}{%= inlineResources(ps.NoStyle, ps.NoScript) %}{%- else -%} {% if !ps.NoStyle %} {%s= assets.StylesheetElement(`client.css`) %}{% endif %}{% if !ps.NoScript %} {%s= assets.ScriptElement(`client.js`, false) %}{% endif %} {%- endif -%} {% endfunc %}
{% func inlineResources(noStyle bool, noScript bool) %}{% stripspace %} {%- if !noStyle -%} {% code css, _ := assets.Embed("client.css") %} <style>{%s= string(css.Bytes) %}</style> {%- endif -%} {%- if !noScript -%} {% code js, _ := assets.Embed("client.js") %} <script>{%s= string(js.Bytes) %}</script> {%- endif -%} {% endstripspace %}{% endfunc %}
|