File tree Expand file tree Collapse file tree 2 files changed +38
-8
lines changed Expand file tree Collapse file tree 2 files changed +38
-8
lines changed Original file line number Diff line number Diff line change 11{ lib , pkgs , ... } :
2+ let
3+ # Replaces absolute links to the docs with relative links
4+ # FIXME: use pandoc filters to do this with an AST
5+ fixLinks =
6+ name : src :
7+ pkgs . runCommand name
8+ {
9+ inherit src ;
10+ github = "https://github.com/nix-community/nixvim/blob/main/" ;
11+ baseurl = "https://nix-community.github.io/nixvim/" ;
12+ }
13+ ''
14+
15+ cp $src $out
16+
17+ # replace relative links with links to github
18+ # TODO: it'd be nice to match relative links without a leading ./
19+ # but that is less trivial
20+ substituteInPlace $out --replace-quiet "./" "$github"
21+
22+ # replace absolute links
23+ substituteInPlace $out --replace-quiet "$baseurl" "./"
24+
25+ # TODO: replace .html with .md
26+ '' ;
27+ in
228{
329 options . enableMan = lib . mkOption {
430 type = lib . types . bool ;
1743 ] ;
1844
1945 config . docs = {
20- # TODO: contributing page
2146 pages . "" = {
2247 menu . section = "header" ;
2348 menu . location = [ "Home" ] ;
24- source = pkgs . callPackage ./readme.nix {
25- # TODO: get `availableVersions` and `baseHref` from module options
26- } ;
49+ source =
50+ let
51+ src = pkgs . callPackage ./readme.nix {
52+ # TODO: get `availableVersions` and `baseHref` from module options
53+ } ;
54+ in
55+ fixLinks src . name src ;
56+ } ;
57+ pages . contributing = {
58+ menu . section = "footer" ;
59+ menu . location = [ "Contributing" ] ;
60+ source = fixLinks "contributing" ../../CONTRIBUTING.md ;
2761 } ;
2862 optionPages . docs = {
2963 optionScopes = [ "docs" ] ;
Original file line number Diff line number Diff line change @@ -21,15 +21,11 @@ runCommand "index.md"
2121 {
2222 start = "<!-- START DOCS -->" ;
2323 end = "<!-- STOP DOCS -->" ;
24- baseurl = "https://nix-community.github.io/nixvim/" ;
2524 src = ../../README.md ;
2625 }
2726 ''
2827 # extract relevant section of the README
2928 sed -n "/$start/,/$end/p" $src > $out
30- # replace absolute links
31- substituteInPlace $out --replace-quiet "$baseurl" "./"
32- # TODO: replace .html with .md
3329 '' ;
3430
3531 docs_versions =
You can’t perform that action at this time.
0 commit comments