Skip to content

Commit 4d3b447

Browse files
committed
modules/docs: add CONTRIBUTING page
1 parent 907db14 commit 4d3b447

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

modules/docs/default.nix

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
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;
@@ -17,13 +43,21 @@
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" ];

modules/docs/readme.nix

-4
Original file line numberDiff line numberDiff 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 =

0 commit comments

Comments
 (0)