BUGFIX: reformat .eleventy.js && output.css

This commit is contained in:
Simon Martens
2024-10-07 15:16:10 +02:00
parent aea014b26d
commit 0969272567
2 changed files with 220 additions and 170 deletions

View File

@@ -1,185 +1,235 @@
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation"); const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function (config) { module.exports = function (config) {
// Configures the development server
config.setServerOptions({
// Default values are shown:
// Configures the development server // Whether the live reload snippet is used
config.setServerOptions({ liveReload: true,
// Default values are shown:
// Whether the live reload snippet is used
liveReload: true,
// Whether DOM diffing updates are applied where possible instead of page reloads
domDiff: true,
// The starting port number
// Will increment up to (configurable) 10 times if a port is already in use.
port: 8080,
// Additional files to watch that will trigger server updates
// Accepts an Array of file paths or globs (passed to `chokidar.watch`).
// Works great with a separate bundler writing files to your output folder.
// e.g. `watch: ["_site/**/*.css"]`
watch: [],
// Show local network IP addresses for device testing
showAllHosts: true,
// Use a local key/certificate to opt-in to local HTTP/2 with https
https: {
// key: "./localhost.key",
// cert: "./localhost.cert",
},
// Change the default file encoding for reading/serving files
encoding: "utf-8",
});
// Whether DOM diffing updates are applied where possible instead of page reloads
domDiff: true,
// Collections: Übersetzungen, Sekundärliteratur, Theateraufführungen, Selbstständige und unselbstständige Drucke, Poshume Ausgaben, Forschungbibliografie // The starting port number
// Reads in the Collections based on folder name and sorts them according to the rules provided by the function // Will increment up to (configurable) 10 times if a port is already in use.
config.addCollection("uebersetzungen", function(collectionApi) { port: 8080,
return collectionApi
.getFilteredByGlob("**/lists/uebersetzungen/*.html")
.sort(function(a, b) {
if (a.data.Sprache !== null && b.data.Sprache !== null &&
a.data.Sprache !== b.data.Sprache) {
return a.data.Sprache.localeCompare(b.data.Sprache);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("sekundaer", function(collectionApi) { // Additional files to watch that will trigger server updates
return collectionApi // Accepts an Array of file paths or globs (passed to `chokidar.watch`).
.getFilteredByGlob("**/lists/sekundaerliteratur/*.html") // Works great with a separate bundler writing files to your output folder.
.sort(function(a, b) { // e.g. `watch: ["_site/**/*.css"]`
if (a.data.Jahr !== null && b.data.Jahr !== null && watch: [],
a.data.Jahr !== b.data.Jahr) {
return a.data.Jahr - b.data.Jahr;
} else if ( a.data.Autor !== null && b.data.Autor !== null &&
a.data.Autor !== b.data.Autor) {
return a.data.Autor.localeCompare(b.data.Autor);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("theater", function(collectionApi) { // Show local network IP addresses for device testing
return collectionApi showAllHosts: true,
.getFilteredByGlob("**/lists/theaterauffuehrungen/*.html")
.sort(function(a, b) {
if (a.data.Jahr !== null && b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr) {
return a.data.Jahr - b.data.Jahr;
} else if ( a.data.Name !== null && b.data.Name !== null &&
a.data.Name !== b.data.Name) {
return a.data.Name.localeCompare(b.data.Name);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("selbststaendigedrucke", function(collectionApi) { // Use a local key/certificate to opt-in to local HTTP/2 with https
return collectionApi https: {
.getFilteredByGlob("**/lists/selbststaendige_drucke/*.html") // key: "./localhost.key",
.sort(function(a, b) { // cert: "./localhost.cert",
if (a.data.Jahr !== null && b.data.Jahr !== null && },
a.data.Jahr !== b.data.Jahr) {
return a.data.Jahr - b.data.Jahr;
} else if ( a.data.Autor !== null && b.data.Autor !== null &&
a.data.Autor !== b.data.Autor) {
return a.data.Autor.localeCompare(b.data.Autor);
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("posthumeausgaben", function(collectionApi) { // Change the default file encoding for reading/serving files
return collectionApi encoding: "utf-8",
.getFilteredByGlob("**/lists/posthume_ausgaben/*.html") });
.sort(function(a, b) {
if (a.data.Jahr !== null && b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr) {
return a.data.Jahr - b.data.Jahr;
} else if (a.data.Sort !== null && b.data.Sort !== null &&
a.data.Sort !== b.data.Sort) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("unselbststaendigedrucke", function(collectionApi) { // Collections: Übersetzungen, Sekundärliteratur, Theateraufführungen, Selbstständige und unselbstständige Drucke, Poshume Ausgaben, Forschungbibliografie
return collectionApi // Reads in the Collections based on folder name and sorts them according to the rules provided by the function
.getFilteredByGlob("**/lists/unselbstaendige_drucke/*.html") config.addCollection("uebersetzungen", function (collectionApi) {
.sort(function(a, b) { return collectionApi
if ( a.data.Werk !== null && b.data.Werk !== null && .getFilteredByGlob("**/lists/uebersetzungen/*.html")
a.data.Werk !== b.data.Werk) { .sort(function (a, b) {
return a.data.Werk.localeCompare(b.data.Werk); if (
} else if (a.data.Sort !== null && b.data.Sort !== null && a.data.Sprache &&
a.data.Sort !== b.data.Sort) { b.data.Sprache &&
return a.data.Sort - b.data.Sort; a.data.Sprache !== b.data.Sprache
} ) {
return 0; return a.data.Sprache.localeCompare(b.data.Sprache);
}); } else if (
}); a.data.Sort !== null &&
a.data.Sort !== undefined &&
b.data.Sort !== null &&
b.data.Sort !== undefined &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("handschriften", function(collectionApi) { config.addCollection("sekundaer", function (collectionApi) {
return collectionApi return collectionApi
.getFilteredByGlob("**/lists/handschriften/*.html") .getFilteredByGlob("**/lists/sekundaerliteratur/*.html")
.sort(function(a, b) { .sort(function (a, b) {
if ( a.data.Ort !== null && b.data.Ort !== null && if (
a.data.Ort !== b.data.Ort) { a.data.Jahr !== null &&
return a.data.Ort.localeCompare(b.data.Ort); b.data.Jahr !== null &&
} else if (a.data.Sort !== null && b.data.Sort !== null && a.data.Jahr !== b.data.Jahr
a.data.Sort !== b.data.Sort) { ) {
return a.data.Sort - b.data.Sort; return a.data.Jahr - b.data.Jahr;
} } else if (
return 0; a.data.Autor !== null &&
}); b.data.Autor !== null &&
}); a.data.Autor !== b.data.Autor
) {
return a.data.Autor.localeCompare(b.data.Autor);
} else if (
a.data.Sort !== null &&
b.data.Sort !== null &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
// Uses the semi-official "navigation"-plugin for eleventy config.addCollection("theater", function (collectionApi) {
config.addPlugin(eleventyNavigationPlugin); return collectionApi
.getFilteredByGlob("**/lists/theaterauffuehrungen/*.html")
// Set static folder, which copntent will be copied to the output folder .sort(function (a, b) {
config.addPassthroughCopy({ "src/static/": "/static/" }); if (
a.data.Jahr !== null &&
b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr
) {
return a.data.Jahr - b.data.Jahr;
} else if (
a.data.Name !== null &&
b.data.Name !== null &&
a.data.Name !== b.data.Name
) {
return a.data.Name.localeCompare(b.data.Name);
} else if (
a.data.Sort !== null &&
b.data.Sort !== null &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
// Output directory config.addCollection("selbststaendigedrucke", function (collectionApi) {
var outputdir = "site"; return collectionApi
if (process.env.ELEVENTY_ENVIRONMENT == "production") { .getFilteredByGlob("**/lists/selbststaendige_drucke/*.html")
outputdir = "docs"; .sort(function (a, b) {
} if (
a.data.Jahr !== null &&
b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr
) {
return a.data.Jahr - b.data.Jahr;
} else if (
a.data.Autor !== null &&
b.data.Autor !== null &&
a.data.Autor !== b.data.Autor
) {
return a.data.Autor.localeCompare(b.data.Autor);
} else if (
a.data.Sort !== null &&
b.data.Sort !== null &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addShortcode("year", () => `${new Date().getFullYear()}`); config.addCollection("posthumeausgaben", function (collectionApi) {
config.addShortcode("month", () => `${new Date().getMonth() + 1}`); return collectionApi
config.addShortcode("day", () => `${new Date().getDate()}`); .getFilteredByGlob("**/lists/posthume_ausgaben/*.html")
.sort(function (a, b) {
if (
a.data.Jahr !== null &&
b.data.Jahr !== null &&
a.data.Jahr !== b.data.Jahr
) {
return a.data.Jahr - b.data.Jahr;
} else if (
a.data.Sort !== null &&
b.data.Sort !== null &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
return { config.addCollection("unselbststaendigedrucke", function (collectionApi) {
// Set custom directories for dynamic pages, data, includes, layouts and finally the generated output return collectionApi
dir: .getFilteredByGlob("**/lists/unselbstaendige_drucke/*.html")
{ .sort(function (a, b) {
input: "src/dynamic", if (
layouts: "../layouts", a.data.Werk !== null &&
includes: "../includes", b.data.Werk !== null &&
data: "../data", a.data.Werk !== b.data.Werk
output: outputdir ) {
}, return a.data.Werk.localeCompare(b.data.Werk);
} else if (
// Set template formats so that other files won't be included in dist a.data.Sort !== null &&
templateFormats: ["njk", "md", "liquid", "html"] b.data.Sort !== null &&
}; a.data.Sort !== b.data.Sort
}; ) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
config.addCollection("handschriften", function (collectionApi) {
return collectionApi
.getFilteredByGlob("**/lists/handschriften/*.html")
.sort(function (a, b) {
if (
a.data.Ort !== null &&
b.data.Ort !== null &&
a.data.Ort !== b.data.Ort
) {
return a.data.Ort.localeCompare(b.data.Ort);
} else if (
a.data.Sort !== null &&
b.data.Sort !== null &&
a.data.Sort !== b.data.Sort
) {
return a.data.Sort - b.data.Sort;
}
return 0;
});
});
// Uses the semi-official "navigation"-plugin for eleventy
config.addPlugin(eleventyNavigationPlugin);
// Set static folder, which copntent will be copied to the output folder
config.addPassthroughCopy({ "src/static/": "/static/" });
// Output directory
var outputdir = "site";
if (process.env.ELEVENTY_ENVIRONMENT == "production") {
outputdir = "docs";
}
config.addShortcode("year", () => `${new Date().getFullYear()}`);
config.addShortcode("month", () => `${new Date().getMonth() + 1}`);
config.addShortcode("day", () => `${new Date().getDate()}`);
return {
// Set custom directories for dynamic pages, data, includes, layouts and finally the generated output
dir: {
input: "src/dynamic",
layouts: "../layouts",
includes: "../includes",
data: "../data",
output: outputdir,
},
// Set template formats so that other files won't be included in dist
templateFormats: ["njk", "md", "liquid", "html"],
};
};

File diff suppressed because one or more lines are too long