feat: robots txt, baseurl
This commit is contained in:
parent
27f5d1bd67
commit
3a5d9ee9a6
@ -1 +1,2 @@
|
|||||||
|
baseurl = "http://127.0.0.1:8080"
|
||||||
title = "test site"
|
title = "test site"
|
10
pkgs-lib.nix
10
pkgs-lib.nix
@ -64,12 +64,20 @@ in
|
|||||||
)
|
)
|
||||||
(readDir path);
|
(readDir path);
|
||||||
siteConfig = fromTOML (readFile (src + "/config.toml"));
|
siteConfig = fromTOML (readFile (src + "/config.toml"));
|
||||||
|
baseurl = siteConfig.baseurl or (throw "Need baseurl");
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
inherit utils pkgs;
|
inherit utils pkgs baseurl;
|
||||||
config = siteConfig;
|
config = siteConfig;
|
||||||
posts = postsRendered;
|
posts = postsRendered;
|
||||||
pages = pagesRendered;
|
pages = pagesRendered;
|
||||||
|
site = {
|
||||||
|
"robots.txt" = ''
|
||||||
|
User-agent: *
|
||||||
|
Allow: /
|
||||||
|
Sitemap: ${baseurl}/sitemap.xml
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
(templater context).site;
|
(templater context).site;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ utils, posts, pkgs, config, pages, ... }@context:
|
{ utils, posts, pkgs, config, pages, site, baseurl, ... }@context:
|
||||||
let
|
let
|
||||||
inherit (utils) readFile mapAttrsToList tags fetchGit map elemAt foldl';
|
inherit (utils) readFile mapAttrsToList tags fetchGit map elemAt foldl';
|
||||||
inherit (pkgs.lib) optional length splitString mapAttrs' nameValuePair;
|
inherit (pkgs.lib) optional length splitString mapAttrs' nameValuePair;
|
||||||
@ -6,7 +6,7 @@ let
|
|||||||
stylesheets = map tags.mkStylesheet [
|
stylesheets = map tags.mkStylesheet [
|
||||||
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
||||||
"https://unpkg.com/purecss@2.0.6/build/grids-responsive-min.css"
|
"https://unpkg.com/purecss@2.0.6/build/grids-responsive-min.css"
|
||||||
"mine.css"
|
"${baseurl}/site.css"
|
||||||
];
|
];
|
||||||
|
|
||||||
renderPost = { name, value }:
|
renderPost = { name, value }:
|
||||||
@ -22,8 +22,8 @@ let
|
|||||||
|
|
||||||
pagesSection =
|
pagesSection =
|
||||||
(map
|
(map
|
||||||
(name: tags.div { class = "pure-u-1"; } (tags.a { href = "./${name}.html"; class = "postheader"; } name))
|
(name: tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}/${name}.html"; class = "postheader"; } name))
|
||||||
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "./index.html"; class = "postheader"; } "posts")) ];
|
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}/index.html"; class = "postheader"; } "posts")) ];
|
||||||
|
|
||||||
postsSectionContent = with tags; [
|
postsSectionContent = with tags; [
|
||||||
(a { href = "#posts"; class = "postheader"; } (h1 "# posts"))
|
(a { href = "#posts"; class = "postheader"; } (h1 "# posts"))
|
||||||
@ -37,13 +37,16 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
mkPage = content: with tags;
|
mkPage = content: with tags;
|
||||||
html [
|
''
|
||||||
(head (stylesheets ++ [
|
<!DOCTYPE html>
|
||||||
(title config.title)
|
${html [
|
||||||
(meta { name = "viewport"; content = "width=device-width, initial-scale=1"; })
|
(head (stylesheets ++ [
|
||||||
]))
|
(title config.title)
|
||||||
(body (sidebarSection ++ [ (div { class = "content"; } content) ]))
|
(meta { name = "viewport"; content = "width=device-width, initial-scale=1"; })
|
||||||
];
|
]))
|
||||||
|
(body (sidebarSection ++ [ (div { class = "content"; } content) ]))
|
||||||
|
]}
|
||||||
|
'';
|
||||||
|
|
||||||
stylesheet =
|
stylesheet =
|
||||||
with utils.css;
|
with utils.css;
|
||||||
@ -97,8 +100,8 @@ in
|
|||||||
{
|
{
|
||||||
inherit stylesheets sidebarSection mkPage stylesheet;
|
inherit stylesheets sidebarSection mkPage stylesheet;
|
||||||
|
|
||||||
site = {
|
site = site // {
|
||||||
"index.html" = mkPage postsSectionContent;
|
"index.html" = mkPage postsSectionContent;
|
||||||
"mine.css" = stylesheet;
|
"site.css" = stylesheet;
|
||||||
} // (mapAttrs' (name: value: nameValuePair (name + ".html") (mkPage value)) pages);
|
} // (mapAttrs' (name: value: nameValuePair (name + ".html") (mkPage value)) pages);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user