refactor(web/tvl/template): Make static asset URL configurable

Change-Id: I168924cd7b15103d64c9ad72172f72304e1d3a7d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3659
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2021-10-01 01:12:40 +03:00 committed by tazjin
parent ce575bf65b
commit 5c9c4aa566
3 changed files with 6 additions and 8 deletions

View file

@ -12,7 +12,7 @@ let
index = depot.web.tvl.template {
title = "TVL (The Virus Lounge) - Software consulting";
content = builtins.readFile ./content.md;
useUrls = true; # load resources from tvl.fyi
staticUrl = "https://tvl.fyi/static";
extraFooter = "\n|\n © ООО ТВЛ";
# TODO(tazjin): The `.tvl-logo` thing can probably go in the shared CSS.

View file

@ -1,8 +1,8 @@
{ depot, ... }:
depot.web.tvl.template {
useUrls = true;
title = "atward";
staticUrl = "https://tvl.fyi/static";
content = ''
atward
======

View file

@ -8,15 +8,13 @@
, extraHead ? null
# optional extra html to inject into <footer>
, extraFooter ? null
# whether to use global URLs instead of absolute paths
, useUrls ? false
# URL at which static assets are located
, staticUrl ? "/static"
}@args:
let
inherit (pkgs) runCommandNoCC lib;
inherit (depot.tools) cheddar;
baseUrl = lib.optionalString useUrls "https://tvl.fyi";
in
runCommandNoCC "index.html" {
@ -26,8 +24,8 @@ runCommandNoCC "index.html" {
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The Virus Lounge">
<link rel="stylesheet" type="text/css" href="${baseUrl}/static/tvl.css" media="all">
<link rel="icon" type="image/webp" href="${baseUrl}/static/favicon.webp">
<link rel="stylesheet" type="text/css" href="${staticUrl}/tvl.css" media="all">
<link rel="icon" type="image/webp" href="${staticUrl}/favicon.webp">
<title>${title}</title>
'' + lib.optionalString (args ? extraHead) extraHead + ''
</head>