docs: add status to beta/deprecated version links
Some checks are pending
Publish every Git push to main to FlakeHub / flakehub-publish (push) Waiting to run
Publish every git push to Flakestry / publish-flake (push) Waiting to run
Documentation / Version info (push) Waiting to run
Documentation / Build (push) Blocked by required conditions
Documentation / Combine builds (push) Blocked by required conditions
Documentation / Deploy (push) Blocked by required conditions

This commit is contained in:
Matt Sturgeon 2025-06-17 23:17:53 +01:00
parent ada9f560c3
commit aef7b53979
4 changed files with 48 additions and 8 deletions

View file

@ -63,12 +63,12 @@ jobs:
| { | {
"branch": .value.branch, "branch": .value.branch,
"nixpkgsBranch": .value.channel, "nixpkgsBranch": .value.channel,
"baseHref": "/nixvim/\(.key)/" "baseHref": "/nixvim/\(.key)/",
"status": .value.status
} }
| select(.branch == "main").baseHref = "/nixvim/" | select(.branch == "main").baseHref = "/nixvim/"
] ]
' version-info.toml ' version-info.toml
# TODO: add channel status
build: build:
name: Build ${{ matrix.name }} name: Build ${{ matrix.name }}

View file

@ -8,7 +8,7 @@ title = "nixvim docs"
[output.html] [output.html]
site-url = "@SITE_URL@" site-url = "@SITE_URL@"
additional-js = ["theme/pagetoc.js"] additional-js = ["theme/pagetoc.js"]
additional-css = ["theme/pagetoc.css"] additional-css = ["custom.css", "theme/pagetoc.css"]
# Redirect targets must be relative to their origin; # Redirect targets must be relative to their origin;
# absolute paths can break with different baseHrefs. # absolute paths can break with different baseHrefs.

19
docs/mdbook/custom.css Normal file
View file

@ -0,0 +1,19 @@
.label {
padding: 0.1rem 0.4em;
font-size: 0.8em;
font-weight: 600;
vertical-align: bottom;
background-color: #5a6165;
text-shadow: rgba(0, 0, 0, 0.25) 0px -1px 0px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.label-info {
background-color: #337798;
}
.label-warning {
background-color: #da8206;
}

View file

@ -11,7 +11,7 @@
# The root directory of the site # The root directory of the site
baseHref ? "/", baseHref ? "/",
# A list of all available docs that should be linked to # 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 ? [ ], availableVersions ? [ ],
}: }:
let let
@ -306,9 +306,9 @@ let
# Zip the list of attrs into an attr of lists, for use as bash arrays # Zip the list of attrs into an attr of lists, for use as bash arrays
zippedVersions = zippedVersions =
assert lib.assertMsg 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; lib.zipAttrs availableVersions;
in in
@ -338,9 +338,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
{ type, hasExt, ... }: { type, hasExt, ... }:
type == "regular" type == "regular"
&& lib.any hasExt [ && lib.any hasExt [
"css"
"js"
"md" "md"
"toml" "toml"
"js"
] ]
) ./.) ) ./.)
]; ];
@ -442,6 +443,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
branches = zippedVersions.branch or [ ]; branches = zippedVersions.branch or [ ];
nixpkgsBranches = zippedVersions.nixpkgsBranch or [ ]; nixpkgsBranches = zippedVersions.nixpkgsBranch or [ ];
baseHrefs = zippedVersions.baseHref or [ ]; baseHrefs = zippedVersions.baseHref or [ ];
statuses = zippedVersions.status or [ ];
current = baseHref; current = baseHref;
} }
'' ''
@ -451,6 +453,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
nixpkgs="''${nixpkgsBranches[i]}" nixpkgs="''${nixpkgsBranches[i]}"
baseHref="''${baseHrefs[i]}" baseHref="''${baseHrefs[i]}"
linkText="\`$branch\` branch" linkText="\`$branch\` branch"
status="''${statuses[i]}"
link= link=
suffix= suffix=
@ -462,7 +465,25 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
link="[$linkText]($baseHref)" link="[$linkText]($baseHref)"
fi 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 done
''; '';
user-configs = callPackage ../user-configs { }; user-configs = callPackage ../user-configs { };