diff --git a/overview/default.nix b/overview/default.nix index a7c47784c..521f66202 100644 --- a/overview/default.nix +++ b/overview/default.nix @@ -30,6 +30,8 @@ let mapAttrsToList optionalString recursiveUpdate + mapAttrs' + nameValuePair ; empty = @@ -146,34 +148,79 @@ let ''; }; - projects = rec { + projects = { one = name: project: '' -
${heading 2 name} + ${heading 1 name} ${render.packages.many (pick.packages project)} ${render.options.many (pick.options project)} ${render.examples.many (pick.examples project)} -
''; - many = projects: concatLines (mapAttrsToList one projects); + # Many projects are renderes as links to their individual project sites + many = + projects: + concatLines ( + mapAttrsToList (name: _: '' + ${name} + '') projects + ); }; }; - metadata = pkgs.writeText "metadata.json" ( - toJSON ( - import ./metadata.nix { - date = lastModified; - } - ) - ); - - content = pkgs.writeText "overview.html" '' + # The top-level overview for all projects + index = pkgs.writeText "index.html" '' + ${heading 1 "NGIpkgs Overview"} ${render.projects.many projects}
''; + + # Every HTML page that we generate + pages = + { + "index.html" = { + pagetitle = "NGIpkgs Overview"; + html = index; + }; + } + // mapAttrs' ( + name: project: + nameValuePair "project/${name}/index.html" { + pagetitle = "NGIpkgs | ${name}"; + html = pkgs.writeText "index.html" (render.projects.one name project); + } + ) projects; + + # Ensure that directories exist and that HTML is complete and works as a standalone file + writeHtmlCommand = + path: + { pagetitle, html, ... }: + let + metadata = pkgs.writeText "metadata.json" (toJSON { + inherit pagetitle; + date = lastModified; + lang = "en"; + dir = "ltr"; + }); + in + '' + mkdir -p "$out/$(dirname '${path}')" + + pandoc \ + --from=markdown+raw_html \ + --to=html \ + --standalone \ + --css="/style.css" \ + --metadata-file=${metadata} \ + --output="$out/${path}" ${html} + + sed --file=${./fixup.sed} \ + --in-place \ + "$out/${path}" + ''; + in pkgs.runCommand "overview" { @@ -184,21 +231,14 @@ pkgs.runCommand "overview" validator-nu ]; } - '' - mkdir -v $out - cp -v ${./style.css} $out/style.css - - pandoc \ - --from=markdown+raw_html \ - --to=html \ - --standalone \ - --css="style.css" \ - --metadata-file=${metadata} \ - --output=$out/index.html ${content} - - sed --file=${./fixup.sed} \ - --in-place \ - $out/index.html - - vnu -Werror --format json $out/*.html | jq - '' + ( + '' + mkdir -v $out + cp -v ${./style.css} $out/style.css + '' + + (concatLines (mapAttrsToList writeHtmlCommand pages)) + + '' + + vnu -Werror --format json $out/*.html | jq + '' + ) diff --git a/overview/metadata.nix b/overview/metadata.nix deleted file mode 100644 index ba726a9a4..000000000 --- a/overview/metadata.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ date }: -{ - inherit date; - title = "NGIpkgs Overview"; - lang = "en"; - dir = "ltr"; -}