Skip to content

Commit 9f487ea

Browse files
committed
docs: add status to beta/deprecated version links
(cherry picked from commit aef7b53)
1 parent 8903683 commit 9f487ea

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

.github/workflows/website.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ jobs:
6363
| {
6464
"branch": .value.branch,
6565
"nixpkgsBranch": .value.channel,
66-
"baseHref": "/nixvim/\(.key)/"
66+
"baseHref": "/nixvim/\(.key)/",
67+
"status": .value.status
6768
}
6869
| select(.branch == "main").baseHref = "/nixvim/"
6970
]
7071
' version-info.toml
71-
# TODO: add channel status
7272
7373
build:
7474
name: Build ${{ matrix.name }}

docs/mdbook/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title = "nixvim docs"
88
[output.html]
99
site-url = "@SITE_URL@"
1010
additional-js = ["theme/pagetoc.js"]
11-
additional-css = ["theme/pagetoc.css"]
11+
additional-css = ["custom.css", "theme/pagetoc.css"]
1212

1313
[output.html.fold]
1414
enable = true

docs/mdbook/custom.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.label {
2+
padding: 0.1rem 0.4em;
3+
font-size: 0.8em;
4+
font-weight: 600;
5+
vertical-align: bottom;
6+
background-color: #5a6165;
7+
text-shadow: rgba(0, 0, 0, 0.25) 0px -1px 0px;
8+
-webkit-border-radius: 3px;
9+
-moz-border-radius: 3px;
10+
border-radius: 3px;
11+
}
12+
13+
.label-info {
14+
background-color: #337798;
15+
}
16+
17+
.label-warning {
18+
background-color: #da8206;
19+
}

docs/mdbook/default.nix

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The root directory of the site
1111
baseHref ? "/",
1212
# A list of all available docs that should be linked to
13-
# Each element should contain { branch; nixpkgsBranch; baseHref; }
13+
# Each element should contain { branch; nixpkgsBranch; baseHref; status; }
1414
availableVersions ? [ ],
1515
}:
1616
let
@@ -305,9 +305,9 @@ let
305305
# Zip the list of attrs into an attr of lists, for use as bash arrays
306306
zippedVersions =
307307
assert lib.assertMsg
308-
(lib.all (o: o ? branch && o ? nixpkgsBranch && o ? baseHref) availableVersions)
308+
(lib.all (o: o ? branch && o ? nixpkgsBranch && o ? baseHref && o ? status) availableVersions)
309309
''
310-
Expected all "availableVersions" docs entries to contain { branch, nixpkgsBranch, baseHref } attrs!
310+
Expected all "availableVersions" docs entries to contain { branch, nixpkgsBranch, baseHref, status } attrs!
311311
'';
312312
lib.zipAttrs availableVersions;
313313
in
@@ -337,9 +337,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
337337
{ type, hasExt, ... }:
338338
type == "regular"
339339
&& lib.any hasExt [
340+
"css"
341+
"js"
340342
"md"
341343
"toml"
342-
"js"
343344
]
344345
) ./.)
345346
];
@@ -428,6 +429,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
428429
branches = zippedVersions.branch or [ ];
429430
nixpkgsBranches = zippedVersions.nixpkgsBranch or [ ];
430431
baseHrefs = zippedVersions.baseHref or [ ];
432+
statuses = zippedVersions.status or [ ];
431433
current = baseHref;
432434
}
433435
''
@@ -437,6 +439,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
437439
nixpkgs="''${nixpkgsBranches[i]}"
438440
baseHref="''${baseHrefs[i]}"
439441
linkText="\`$branch\` branch"
442+
status="''${statuses[i]}"
440443
441444
link=
442445
suffix=
@@ -448,7 +451,25 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
448451
link="[$linkText]($baseHref)"
449452
fi
450453
451-
echo "- The $link, for use with nixpkgs \`$nixpkgs\`$suffix" >> "$out"
454+
statusClass=
455+
statusText=
456+
if [ "$status" = "beta" ]; then
457+
statusClass="label label-info"
458+
statusText=Beta
459+
elif [ "$status" = "deprecated" ]; then
460+
statusClass="label label-warning"
461+
statusText=Deprecated
462+
fi
463+
464+
{
465+
echo -n '- '
466+
if [ -n "$statusClass" ] && [ -n "$statusText" ]; then
467+
echo -n '<span class="'"$statusClass"'">'"$statusText"'</span> '
468+
fi
469+
echo -n "The $link"
470+
echo -n ", for use with nixpkgs \`$nixpkgs\`"
471+
echo "$suffix"
472+
} >> "$out"
452473
done
453474
'';
454475
user-configs = callPackage ../user-configs { };

0 commit comments

Comments
 (0)