feat: added site map

This commit is contained in:
Leyla Becker 2026-02-11 15:51:26 -06:00
parent 7682677cf6
commit a7676d06b6
9 changed files with 62 additions and 21 deletions

1
.gitignore vendored
View file

@ -24,6 +24,7 @@ _site
# nix packages # nix packages
.direnv .direnv
result
# Environment variables # Environment variables
.env .env

7
_data/site.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
// Set SITE_URL environment variable to build for different domains:
// SITE_URL=https://blog.jan-leila.com pnpm run build
// SITE_URL=https://volpe.jan-leila.com pnpm run build
// SITE_URL=http://your-onion-address.onion pnpm run build
url: process.env.SITE_URL || "http://localhost:8080"
};

View file

@ -223,6 +223,8 @@ module.exports = (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("css"); eleventyConfig.addPassthroughCopy("css");
eleventyConfig.addPassthroughCopy("robots.txt"); eleventyConfig.addPassthroughCopy("robots.txt");
eleventyConfig.ignores.add("README.md");
return { return {
dir: { dir: {
input: ".", input: ".",

View file

@ -20,8 +20,15 @@
}); });
in { in {
packages = forEachSupportedSystem ({pkgs}: { packages = forEachSupportedSystem ({pkgs}: {
default = pkgs.callPackage ./nix/package.nix {}; default = pkgs.callPackage ./nix/package.nix {
volpe = pkgs.callPackage ./nix/package.nix {}; siteUrl = "https://blog.jan-leila.com";
};
blog = pkgs.callPackage ./nix/package.nix {
siteUrl = "https://blog.jan-leila.com";
};
volpe = pkgs.callPackage ./nix/package.nix {
siteUrl = "https://volpe.jan-leila.com";
};
}); });
devShells = forEachSupportedSystem ({pkgs}: { devShells = forEachSupportedSystem ({pkgs}: {

View file

@ -1,8 +1,4 @@
{ {...}: {
config,
pkgs,
...
}: {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./module.nix ./module.nix

View file

@ -5,21 +5,35 @@
... ...
}: let }: let
cfg = config.services.volpe; cfg = config.services.volpe;
pkg = pkgs.callPackage ./package.nix {};
mkPkg = domain:
pkgs.callPackage ./package.nix {
siteUrl = "https://${domain}";
};
allDomains = [cfg.domain] ++ cfg.extraDomains;
mkVirtualHost = domain: {
root = "${mkPkg domain}";
forceSSL = cfg.enableACME;
enableACME = cfg.enableACME;
locations."/" = {
tryFiles = "$uri $uri/ /index.html";
};
};
in { in {
options.services.volpe = { options.services.volpe = {
enable = lib.mkEnableOption "volpe blog"; enable = lib.mkEnableOption "volpe blog";
domain = lib.mkOption { domain = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "localhost";
description = "Primary domain name for nginx virtual host."; description = "Primary domain name for nginx virtual host.";
}; };
extraDomains = lib.mkOption { extraDomains = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
description = "Additional domain names (aliases) for the virtual host."; description = "Additional domain names, each gets its own virtualHost.";
}; };
enableACME = lib.mkOption { enableACME = lib.mkOption {
@ -43,15 +57,12 @@ in {
recommendedGzipSettings = true; recommendedGzipSettings = true;
recommendedProxySettings = true; recommendedProxySettings = true;
virtualHosts.${cfg.domain} = { # Create a virtualHost for each domain
root = "${pkg}"; virtualHosts = lib.listToAttrs (map (domain: {
serverAliases = cfg.extraDomains; name = domain;
forceSSL = cfg.enableACME; value = mkVirtualHost domain;
enableACME = cfg.enableACME; })
locations."/" = { allDomains);
tryFiles = "$uri $uri/ /index.html";
};
};
}; };
security.acme = lib.mkIf cfg.enableACME { security.acme = lib.mkIf cfg.enableACME {
@ -61,4 +72,4 @@ in {
networking.firewall.allowedTCPPorts = [80 443]; networking.firewall.allowedTCPPorts = [80 443];
}; };
} }

View file

@ -5,6 +5,7 @@
pnpm_10, pnpm_10,
fetchPnpmDeps, fetchPnpmDeps,
pnpmConfigHook, pnpmConfigHook,
siteUrl,
}: let }: let
nodejs = nodejs_latest; nodejs = nodejs_latest;
pnpm = pnpm_10; pnpm = pnpm_10;
@ -31,7 +32,7 @@ in
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
pnpm build SITE_URL="${siteUrl}" pnpm build
runHook postBuild runHook postBuild
''; '';

View file

@ -6,6 +6,7 @@ pagination:
resolve: keys resolve: keys
permalink: /post/{{ slugData }}/ permalink: /post/{{ slugData }}/
layout: base.njk layout: base.njk
excludeFromSitemap: true
--- ---
{% set posts = collections.postsBySlug[slugData] %} {% set posts = collections.postsBySlug[slugData] %}

15
sitemap.njk Normal file
View file

@ -0,0 +1,15 @@
---
permalink: /sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{%- for page in collections.all %}
{%- if page.url and page.url != "/sitemap.xml" and not page.data.excludeFromSitemap %}
<url>
<loc>{{ site.url }}{{ page.url }}</loc>
<lastmod>{{ (page.data.updatedAt or page.data.createdAt or page.date) | isoDate }}</lastmod>
</url>
{%- endif %}
{%- endfor %}
</urlset>