Skip to content

Commit 63b9177

Browse files
committed
modules/docs: use new fix-links impl
1 parent 13916c5 commit 63b9177

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

modules/docs/default.nix

+9-31
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
{ lib, pkgs, ... }:
22
let
33
# 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-
'';
4+
fixLinks = pkgs.callPackage ../../docs/fix-linkx {
5+
githubUrl = "https://github.com/nix-community/nixvim/blob/main/";
6+
baseurlUrl = "https://nix-community.github.io/nixvim/";
7+
};
278
in
289
{
2910
options.enableMan = lib.mkOption {
@@ -46,18 +27,15 @@ in
4627
pages."" = {
4728
menu.section = "header";
4829
menu.location = [ "Home" ];
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;
30+
source = pkgs.callPackage ./readme.nix {
31+
inherit fixLinks;
32+
# TODO: get `availableVersions` and `baseHref` from module options
33+
};
5634
};
5735
pages.contributing = {
5836
menu.section = "footer";
5937
menu.location = [ "Contributing" ];
60-
source = fixLinks "contributing" ../../CONTRIBUTING.md;
38+
source = fixLinks ../../CONTRIBUTING.md;
6139
};
6240
optionPages.docs = {
6341
optionScopes = [ "docs" ];

modules/docs/readme.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
lib,
33
runCommand,
4+
fixLinks,
45
availableVersions ? [ ],
56
baseHref ? "/", # TODO: remove & get from module config
67
}:
@@ -21,7 +22,7 @@ runCommand "index.md"
2122
{
2223
start = "<!-- START DOCS -->";
2324
end = "<!-- STOP DOCS -->";
24-
src = ../../README.md;
25+
src = fixLinks ../../README.md;
2526
}
2627
''
2728
# extract relevant section of the README

0 commit comments

Comments
 (0)