docs: add status to beta/deprecated version links

This commit is contained in:
Matt Sturgeon 2025-06-17 23:17:53 +01:00
parent b4750c4696
commit d3da2462eb
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
4 changed files with 48 additions and 8 deletions

View file

@ -11,7 +11,7 @@
# The root directory of the site
baseHref ? "/",
# A list of all available docs that should be linked to
# Each element should contain { branch; nixpkgsBranch; baseHref; }
# Each element should contain { branch; nixpkgsBranch; baseHref; status; }
availableVersions ? [ ],
}:
let
@ -306,9 +306,9 @@ let
# Zip the list of attrs into an attr of lists, for use as bash arrays
zippedVersions =
assert lib.assertMsg
(lib.all (o: o ? branch && o ? nixpkgsBranch && o ? baseHref) availableVersions)
(lib.all (o: o ? branch && o ? nixpkgsBranch && o ? baseHref && o ? status) availableVersions)
''
Expected all "availableVersions" docs entries to contain { branch, nixpkgsBranch, baseHref } attrs!
Expected all "availableVersions" docs entries to contain { branch, nixpkgsBranch, baseHref, status } attrs!
'';
lib.zipAttrs availableVersions;
in
@ -338,9 +338,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
{ type, hasExt, ... }:
type == "regular"
&& lib.any hasExt [
"css"
"js"
"md"
"toml"
"js"
]
) ./.)
];
@ -442,6 +443,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
branches = zippedVersions.branch or [ ];
nixpkgsBranches = zippedVersions.nixpkgsBranch or [ ];
baseHrefs = zippedVersions.baseHref or [ ];
statuses = zippedVersions.status or [ ];
current = baseHref;
}
''
@ -451,6 +453,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
nixpkgs="''${nixpkgsBranches[i]}"
baseHref="''${baseHrefs[i]}"
linkText="\`$branch\` branch"
status="''${statuses[i]}"
link=
suffix=
@ -462,7 +465,25 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
link="[$linkText]($baseHref)"
fi
echo "- The $link, for use with nixpkgs \`$nixpkgs\`$suffix" >> "$out"
statusClass=
statusText=
if [ "$status" = "beta" ]; then
statusClass="label label-info"
statusText=Beta
elif [ "$status" = "deprecated" ]; then
statusClass="label label-warning"
statusText=Deprecated
fi
{
echo -n '- '
if [ -n "$statusClass" ] && [ -n "$statusText" ]; then
echo -n '<span class="'"$statusClass"'">'"$statusText"'</span> '
fi
echo -n "The $link"
echo -n ", for use with nixpkgs \`$nixpkgs\`"
echo "$suffix"
} >> "$out"
done
'';
user-configs = callPackage ../user-configs { };