Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/site/_data/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ module.exports = async (data) => {
// Use the first match and convert to site-relative path
logoPath = "/" + logoFiles[0].split("src/site/")[1];
}

// Logo height override. A bare number means pixels; any other value must
// be a simple CSS length (e.g. "3rem") — anything else is ignored so the
// env value can't inject arbitrary CSS.
let logoHeight = (process.env.LOGO_HEIGHT || "").trim();
if (/^\d+(\.\d+)?$/.test(logoHeight)) {
logoHeight += "px";
} else if (!/^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch)$/.test(logoHeight)) {
logoHeight = "";
}
if (themeStyle) {
themeStyle = themeStyle.split("site")[1];
}
Expand Down Expand Up @@ -100,6 +110,7 @@ module.exports = async (data) => {
baseTheme: process.env.BASE_THEME || "dark",
siteName: process.env.SITE_NAME_HEADER || "Digital Garden",
siteLogoPath: logoPath,
logoHeight,
mainLanguage: process.env.SITE_MAIN_LANGUAGE || "en",
siteBaseUrl: baseUrl,
styleSettingsCss,
Expand Down
9 changes: 9 additions & 0 deletions src/site/_includes/components/pageheader.njk
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,14 @@
{{ meta.styleSettingsCss | safe }}
</style>
{% endif %}
{% if meta.logoHeight %}
<style>
:root {
--dg-logo-height: {{ meta.logoHeight }};
--dg-logo-height-mobile: {{ meta.logoHeight }};
--dg-filetree-logo-height: {{ meta.logoHeight }};
}
</style>
{% endif %}
<style>
</style>
Loading