docs: configure highlight.js

This commit is contained in:
DavHau 2023-10-23 20:13:06 +01:00 committed by mergify[bot]
parent ce51fbf18b
commit cf82f7a1ed
2 changed files with 31 additions and 1 deletions

View File

@ -44,6 +44,24 @@
# '';
packages = {
highlight-js = let
highlight-core = pkgs.fetchurl {
url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js";
hash = "sha256-g3pvpbDHNrUrveKythkPMF2j/J7UFoHbUyFQcFe1yEY=";
};
highlight-nix = pkgs.fetchurl {
url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/nix.min.js";
hash = "sha256-BLoZ+/OroDAxMsdZ4GFZtQfsg6ZJeLVNeBzN/82dYgk=";
};
in
pkgs.runCommand "highlight-js" {} ''
cat ${highlight-core} > $out
cat ${highlight-nix} >> $out
'';
highlight-style = pkgs.fetchurl {
url = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/vs.min.css";
hash = "sha256-E1kfafj5iO+Tw/04hxdSG+OnvczojOXK2K0iCEYfzSw=";
};
website = pkgs.stdenvNoCC.mkDerivation {
name = "website";
nativeBuildInputs = [pkgs.mdbook pkgs.mdbook-linkcheck];
@ -54,9 +72,13 @@
rm ./src/intro.md
cp ${self + /README.md} ./src/intro.md
cp ./src/SUMMARY.md SUMMARY.md.orig
# insert highlight.js
cp ${self'.packages.highlight-js} ./src/highlight.js
cp ${self'.packages.highlight-style} ./src/highlight.css
# insert the generated part of the summary into the origin SUMMARY.md
cp ./src/SUMMARY.md SUMMARY.md.orig
{
while read ln; do
case "$ln" in

View File

@ -17,3 +17,11 @@ h1.menu-title::before {
/* We don't use numbers, so we can take a consistent amount of space */
padding: var(--page-padding) !important;
}
.hljs {
background-color: #f6f7f6;
}
@media (prefers-color-scheme: dark) {
.hljs {
background-color: #1d1f21;
}
}