Skip to content

Commit 13916c5

Browse files
committed
modules/docs: add CONTRIBUTING page
1 parent e7c43d6 commit 13916c5

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

modules/docs/default.nix

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
{ lib, ... }:
1+
{ 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;
@@ -16,8 +42,24 @@
1642
./platforms.nix
1743
];
1844

19-
config.docs.optionPages = {
20-
docs = {
45+
config.docs = {
46+
pages."" = {
47+
menu.section = "header";
48+
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;
56+
};
57+
pages.contributing = {
58+
menu.section = "footer";
59+
menu.location = [ "Contributing" ];
60+
source = fixLinks "contributing" ../../CONTRIBUTING.md;
61+
};
62+
optionPages.docs = {
2163
optionScopes = [ "docs" ];
2264
page.menu.location = [ "docs" ];
2365
page.text = ''

modules/docs/readme.nix

Lines changed: 0 additions & 4 deletions
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)