Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Static site generator (Eleventy) (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
black-backdoor authored Dec 31, 2024
1 parent d259bb6 commit 8d2c6f7
Show file tree
Hide file tree
Showing 35 changed files with 1,952 additions and 1,411 deletions.
27 changes: 27 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const minifyHTML = require("./lib/transfroms/minifyHtml.js");

module.exports = function (config) {
config.addTransform("minifyHtml", minifyHTML);

config.addPassthroughCopy({ "favicons": "/" });
config.addPassthroughCopy("src/**/*.css");
config.addPassthroughCopy("src/**/*.js");
config.addPassthroughCopy("src/**/*.svg");
config.addPassthroughCopy("src/**/*.json");

config.addGlobalData("urlOrigin", process.env.URL_ORIGIN || "http://localhost:8080");

return {
dir: {
input: "src",
output: "dist",
},

"templateFormats": ['njk', 'html'],
"htmlTemplateEngine": "njk",
"markdownTemplateEngine": "njk",
"javascriptTemplateEngine": "njk",
"dataTemplateEngine": "njk",
"passthroughFileCopy": true,
};
};
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:

- name: Build
run: npm run build
env:
URL_ORIGIN: 'https://meos.lima.zone'

- name: 📂 Sync files
uses: SamKirkland/[email protected]
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
20 changes: 20 additions & 0 deletions lib/transfroms/minifyHtml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const htmlmin = require("html-minifier-terser");

module.exports = function (content) {
if (process.env.ELEVENTY_RUN_MODE === "serve") { return content; }

if ((this.page.outputPath || "").endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: false,
collapseWhitespace: true,
// preserveLineBreaks: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
});

return minified;
}

return content;
};
Loading

0 comments on commit 8d2c6f7

Please sign in to comment.