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
.direnv
result
# Environment variables
.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("robots.txt");
eleventyConfig.ignores.add("README.md");
return {
dir: {
input: ".",

View file

@ -20,8 +20,15 @@
});
in {
packages = forEachSupportedSystem ({pkgs}: {
default = pkgs.callPackage ./nix/package.nix {};
volpe = pkgs.callPackage ./nix/package.nix {};
default = 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}: {

View file

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

View file

@ -5,21 +5,35 @@
...
}: let
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 {
options.services.volpe = {
enable = lib.mkEnableOption "volpe blog";
domain = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = "Primary domain name for nginx virtual host.";
};
extraDomains = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "Additional domain names (aliases) for the virtual host.";
description = "Additional domain names, each gets its own virtualHost.";
};
enableACME = lib.mkOption {
@ -43,15 +57,12 @@ in {
recommendedGzipSettings = true;
recommendedProxySettings = true;
virtualHosts.${cfg.domain} = {
root = "${pkg}";
serverAliases = cfg.extraDomains;
forceSSL = cfg.enableACME;
enableACME = cfg.enableACME;
locations."/" = {
tryFiles = "$uri $uri/ /index.html";
};
};
# Create a virtualHost for each domain
virtualHosts = lib.listToAttrs (map (domain: {
name = domain;
value = mkVirtualHost domain;
})
allDomains);
};
security.acme = lib.mkIf cfg.enableACME {

View file

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

View file

@ -6,6 +6,7 @@ pagination:
resolve: keys
permalink: /post/{{ slugData }}/
layout: base.njk
excludeFromSitemap: true
---
{% 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>