feat: added site map
This commit is contained in:
parent
7682677cf6
commit
a7676d06b6
9 changed files with 62 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -24,6 +24,7 @@ _site
|
|||
|
||||
# nix packages
|
||||
.direnv
|
||||
result
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
|
|
|
|||
7
_data/site.js
Normal file
7
_data/site.js
Normal 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"
|
||||
};
|
||||
|
|
@ -223,6 +223,8 @@ module.exports = (eleventyConfig) => {
|
|||
eleventyConfig.addPassthroughCopy("css");
|
||||
eleventyConfig.addPassthroughCopy("robots.txt");
|
||||
|
||||
eleventyConfig.ignores.add("README.md");
|
||||
|
||||
return {
|
||||
dir: {
|
||||
input: ".",
|
||||
|
|
|
|||
11
flake.nix
11
flake.nix
|
|
@ -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}: {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
{...}: {
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./module.nix
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -61,4 +72,4 @@ in {
|
|||
|
||||
networking.firewall.allowedTCPPorts = [80 443];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -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
15
sitemap.njk
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue