Skip to content

Commit 5728c88

Browse files
Add canonical tags
1 parent a5885da commit 5728c88

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

website.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ let
44
h = niccup.lib;
55
isLinux = pkgs.stdenv.isLinux;
66

7+
defaultSiteUrl = "https://emsh.cat/niccup";
8+
siteUrl =
9+
let
10+
raw = builtins.getEnv "NICCUP_SITE_URL";
11+
in pkgs.lib.removeSuffix "/" (if raw != "" then raw else defaultSiteUrl);
12+
13+
canonicalUrl = path: "${siteUrl}${path}";
14+
715
# Discover and build examples
816
exampleDirs = builtins.attrNames (
917
pkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./examples)
@@ -73,6 +81,7 @@ let
7381
[ "head"
7482
[ "meta" { charset = "utf-8"; } ]
7583
[ "title" "${name} - niccup example" ]
84+
[ "link" { rel = "canonical"; href = canonicalUrl "/examples/${name}/"; } ]
7685
[ "style" (h.raw showcaseStyles) ]
7786
]
7887
[ "body"
@@ -119,6 +128,7 @@ let
119128
[ "meta" { charset = "utf-8"; } ]
120129
[ "meta" { name = "viewport"; content = "width=device-width, initial-scale=1"; } ]
121130
[ "title" "niccup - Hiccup-style HTML generation for Nix" ]
131+
[ "link" { rel = "canonical"; href = canonicalUrl "/"; } ]
122132
[ "style" (h.raw homeStyles) ]
123133
]
124134
[ "body"

0 commit comments

Comments
 (0)