Refactor directory layout

This commit is contained in:
Yannik Rödel 2021-09-29 19:43:59 +02:00
parent 50600cfab3
commit eb7123464e
61 changed files with 29 additions and 17 deletions

View file

@ -1,5 +1,7 @@
const { DateTime } = require("luxon");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const { DateTime } = require("luxon");
const pluginRss = require("@11ty/eleventy-plugin-rss"); const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginNavigation = require("@11ty/eleventy-navigation"); const pluginNavigation = require("@11ty/eleventy-navigation");
@ -8,6 +10,7 @@ const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor"); const markdownItAnchor = require("markdown-it-anchor");
const markdownItAttrs = require("markdown-it-attrs"); const markdownItAttrs = require("markdown-it-attrs");
function hyphenize(input) { function hyphenize(input) {
return input.replace(/[^\w- ]/, "").replace(/[_ ]/, "-").toLowerCase(); return input.replace(/[^\w- ]/, "").replace(/[_ ]/, "-").toLowerCase();
} }
@ -72,11 +75,11 @@ ${content}
}); });
eleventyConfig.addPairedAsyncShortcode("banner", async (content, title, backgroundSource, backgroundAlt) => { eleventyConfig.addPairedAsyncShortcode("banner", async (content, title, backgroundSource, backgroundAlt) => {
const backgroundMetadata = await Image(backgroundSource, { const backgroundMetadata = await Image(`src/images/${backgroundSource}`, {
widths: [1200, 1980, 4000], widths: [1200, 1980, 4000],
formats: ["avif", "webp", "jpeg"], formats: ["avif", "webp", "jpeg"],
urlPath: "/assets/img", urlPath: "/assets/img",
outputDir: "./_site/assets/img", outputDir: "./dist/assets/img",
sharpAvifOptions: { quality: 40 }, sharpAvifOptions: { quality: 40 },
sharpWebpOptions: { quality: 50 }, sharpWebpOptions: { quality: 50 },
sharpJpegOptions: { quality: 65 }, sharpJpegOptions: { quality: 65 },
@ -122,12 +125,12 @@ ${
// Build settings // Build settings
// //
eleventyConfig.addPassthroughCopy("assets"); eleventyConfig.addPassthroughCopy({ "src/assets": "assets" });
eleventyConfig.setBrowserSyncConfig({ eleventyConfig.setBrowserSyncConfig({
callbacks: { callbacks: {
ready: function(err, browserSync) { ready: function(err, browserSync) {
const content_404 = fs.readFileSync('_site/404.html'); const content_404 = fs.readFileSync('dist/404.html');
browserSync.addMiddleware("*", (req, res) => { browserSync.addMiddleware("*", (req, res) => {
// Provides the 404 content without redirect. // Provides the 404 content without redirect.
@ -145,7 +148,17 @@ ${
// Other settings // Other settings
// //
return { return {
dir: {
input: 'src/content',
// These are all relative to the input directory so the paths get a little
// weird:
includes: '../includes',
data: '../data',
output: 'dist',
},
templateFormats: [ templateFormats: [
"md", "md",
"njk", "njk",

View file

@ -1,2 +1 @@
README.md
assets/fonts/OFL.txt assets/fonts/OFL.txt

4
.gitignore vendored
View file

@ -1,8 +1,7 @@
node_modules/ node_modules/
# Eleventy build output # Eleventy build output
/assets/css/ dist/
/_site/
# Editor settings # Editor settings
.vscode/ .vscode/
@ -11,4 +10,5 @@ node_modules/
# Environment # Environment
.env .env
# `nix build` output # `nix build` output
/.dev
/result /result

1
.nvmrc
View file

@ -1 +0,0 @@
12

View file

@ -16,10 +16,11 @@ npm run build:styles
npm run dev:site npm run dev:site
``` ```
Go to <https://localhost:8080/>, which will update live when content changes. Go to <https://localhost:8080/>, which will update live when content changes
(the initial build may take some time to render out the different image sizes).
If you make style changes, make sure to recompile the CSS files with the second If you make style changes, make sure to recompile the CSS files with the second
command. Alternatively, run `npm run dev:styles` in a second terminal to watch of the above commands. Alternatively, run `npm run dev:styles` in an additional
for changes. terminal to watch for changes.
### Nix environment ### Nix environment

View file

@ -10,7 +10,7 @@
nodejs = pkgs.nodejs-16_x; nodejs = pkgs.nodejs-16_x;
nodePackages = import ./_nix/default.nix { inherit pkgs system nodejs; }; nodePackages = import ./nix/default.nix { inherit pkgs system nodejs; };
nodeDependencies = nodePackages.nodeDependencies.override { nodeDependencies = nodePackages.nodeDependencies.override {
nativeBuildInputs = with pkgs; [ pkg-config ]; nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ vips ]; buildInputs = with pkgs; [ vips ];

View file

@ -4,7 +4,7 @@
"description": "Angestöpselt Homepage", "description": "Angestöpselt Homepage",
"scripts": { "scripts": {
"build:site": "eleventy", "build:site": "eleventy",
"build:styles": "sass --style=compressed styles/:_site/assets/css/", "build:styles": "sass --style=compressed src/styles/:dist/assets/css/",
"build": "npm run build:site && npm run build:styles", "build": "npm run build:site && npm run build:styles",
"dev:site": "eleventy --serve", "dev:site": "eleventy --serve",
"dev:styles": "npm run build:styles -- --watch" "dev:styles": "npm run build:styles -- --watch"

View file

@ -3,7 +3,7 @@ layout: layouts/home.njk
--- ---
{% banner {% banner
"Angestöpselt", "Angestöpselt",
"images/home-banner.jpg", "home-banner.jpg",
"Kinder und Jugendliche verfolgen die Präsentation eines 3D-Druckers" "Kinder und Jugendliche verfolgen die Präsentation eines 3D-Druckers"
%} %}
Wir bieten Bedürftigen Zugang in die digitale Welt Wir bieten Bedürftigen Zugang in die digitale Welt

View file

@ -7,7 +7,7 @@ eleventyNavigation:
--- ---
{% banner {% banner
"", "",
"images/contact-banner.jpg", "contact-banner.jpg",
"Aufnahme des Vereinsheims bei Nacht. Die Innenbeleuchtung ist an und der Angestöpselt-Schriftzug ist zu sehen." "Aufnahme des Vereinsheims bei Nacht. Die Innenbeleuchtung ist an und der Angestöpselt-Schriftzug ist zu sehen."
%} %}
{% endbanner %} {% endbanner %}

View file

@ -4,7 +4,7 @@ useForms: true
--- ---
{% banner {% banner
"", "",
"images/work-banner.jpg", "work-banner.jpg",
"Nahaufnahme eines Laptops mit geöffnetem Gehäuse. Sichtbar ist die ausgebaute Festplatte." "Nahaufnahme eines Laptops mit geöffnetem Gehäuse. Sichtbar ist die ausgebaute Festplatte."
%} %}
{% endbanner %} {% endbanner %}

View file

Before

Width:  |  Height:  |  Size: 4.2 MiB

After

Width:  |  Height:  |  Size: 4.2 MiB

View file

Before

Width:  |  Height:  |  Size: 9.1 MiB

After

Width:  |  Height:  |  Size: 9.1 MiB

View file

Before

Width:  |  Height:  |  Size: 16 MiB

After

Width:  |  Height:  |  Size: 16 MiB