package updates + image optimization + sourcecode beautification
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Soph :3 2024-08-30 03:55:26 +03:00
parent 662ac680e9
commit caa7aaa02a
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
9 changed files with 94 additions and 77 deletions

View file

@ -1,12 +1,15 @@
import SSSG from "sssg";
import SSSG, { Plugin } from "sssg";
import Variables from "sssg/src/plugins/variables";
import Dev from "sssg/src/plugins/dev";
import TSCompiler from "sssg/src/plugins/ts-compiler";
import MarkdownMetadata, {parseMetadata} from "sssg/src/plugins/markdown-metadata";
import MarkdownMetadata, {
parseMetadata,
} from "sssg/src/plugins/markdown-metadata";
import MarkdownCompiler from "sssg/src/plugins/markdown-compiler";
import CompileTimeJS from "sssg/src/plugins/compile-time-js";
import ImageOptimization from "sssg/src/plugins/image-optimization";
import {$} from "bun"
import { $ } from "bun";
import * as path from "path";
import * as fs from "fs";
@ -16,19 +19,27 @@ const sssg = new SSSG({
inputFolder: path.join(__dirname, "website"),
});
const gitLogShell = await $`git log --pretty=format:'commit=%H%nauthor=%aN <%aE>%ndate=%ad%nmessage=%s%n=========' -1`.quiet()
const gitLogShell =
await $`git log --pretty=format:'commit=%H%nauthor=%aN <%aE>%ndate=%ad%nmessage=%s%n=========' -1`.quiet();
const gitLogOutput = gitLogShell.text("utf8");
const gitLog = JSON.stringify(parseMetadata(gitLogOutput));
const plugins: Plugin[] = [];
if (process.argv.includes("--dev")) {
plugins.push(new Dev(sssg));
} else {
plugins.push(new ImageOptimization());
}
await sssg.run({
plugins: [
plugins: plugins.concat([
new CompileTimeJS(),
new Variables(() => {
const variables: Record<string, string> = {
__BLOG_POSTS__: JSON.stringify(
fs.readdirSync("./website/blogs").map((z) => z.replace(".md", ""))
),
__GIT_LOG_OUTPUT__: gitLog
__GIT_LOG_OUTPUT__: gitLog,
};
if (fs.existsSync("./website/templates")) {
@ -44,8 +55,7 @@ await sssg.run({
new TSCompiler(),
new MarkdownMetadata(),
new MarkdownCompiler(),
new Dev(sssg),
],
]),
});
await sssg.build();