diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 786e2196..1a245405 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -63,12 +63,12 @@ jobs: | { "branch": .value.branch, "nixpkgsBranch": .value.channel, - "baseHref": "/nixvim/\(.key)/" + "baseHref": "/nixvim/\(.key)/", + "status": .value.status } | select(.branch == "main").baseHref = "/nixvim/" ] ' version-info.toml - # TODO: add channel status build: name: Build ${{ matrix.name }} diff --git a/docs/mdbook/book.toml b/docs/mdbook/book.toml index 9776c0c8..1c13fe2b 100644 --- a/docs/mdbook/book.toml +++ b/docs/mdbook/book.toml @@ -8,7 +8,7 @@ title = "nixvim docs" [output.html] site-url = "@SITE_URL@" 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; # absolute paths can break with different baseHrefs. diff --git a/docs/mdbook/custom.css b/docs/mdbook/custom.css new file mode 100644 index 00000000..8a45148b --- /dev/null +++ b/docs/mdbook/custom.css @@ -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; +} diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index b1a3b278..ceddb6a3 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -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 ''"$statusText"' ' + fi + echo -n "The $link" + echo -n ", for use with nixpkgs \`$nixpkgs\`" + echo "$suffix" + } >> "$out" done ''; user-configs = callPackage ../user-configs { };