add git log widget
All checks were successful
/ test (push) Successful in 18s

This commit is contained in:
Soph :3 2024-08-29 23:16:35 +03:00
parent 1efaf2f0b1
commit f75305ebfe
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
5 changed files with 64 additions and 7 deletions

1
global.d.ts vendored
View file

@ -1,4 +1,5 @@
declare global { declare global {
let __BLOG_POSTS__: string[] let __BLOG_POSTS__: string[]
let __GIT_LOG_OUTPUT__: Record<string, string>;
} }
export { }; export { };

View file

@ -2,10 +2,12 @@ import SSSG from "sssg";
import Variables from "sssg/src/plugins/variables"; import Variables from "sssg/src/plugins/variables";
import Dev from "sssg/src/plugins/dev"; import Dev from "sssg/src/plugins/dev";
import TSCompiler from "sssg/src/plugins/ts-compiler"; import TSCompiler from "sssg/src/plugins/ts-compiler";
import MarkdownMetadata from "sssg/src/plugins/markdown-metadata"; import MarkdownMetadata, {parseMetadata} from "sssg/src/plugins/markdown-metadata";
import MarkdownCompiler from "sssg/src/plugins/markdown-compiler"; import MarkdownCompiler from "sssg/src/plugins/markdown-compiler";
import CompileTimeJS from "sssg/src/plugins/compile-time-js"; import CompileTimeJS from "sssg/src/plugins/compile-time-js";
import {$} from "bun"
import * as path from "path"; import * as path from "path";
import * as fs from "fs"; import * as fs from "fs";
@ -14,6 +16,10 @@ const sssg = new SSSG({
inputFolder: path.join(__dirname, "website"), 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 gitLogOutput = gitLogShell.text("utf8");
const gitLog = JSON.stringify(parseMetadata(gitLogOutput));
await sssg.run({ await sssg.run({
plugins: [ plugins: [
new CompileTimeJS(), new CompileTimeJS(),
@ -22,6 +28,7 @@ await sssg.run({
__BLOG_POSTS__: JSON.stringify( __BLOG_POSTS__: JSON.stringify(
fs.readdirSync("./website/blogs").map((z) => z.replace(".md", "")) fs.readdirSync("./website/blogs").map((z) => z.replace(".md", ""))
), ),
__GIT_LOG_OUTPUT__: gitLog
}; };
if (fs.existsSync("./website/templates")) { if (fs.existsSync("./website/templates")) {

View file

@ -18,6 +18,7 @@ a {
grid-template-areas: grid-template-areas:
"details skills" "details skills"
"details donations" "details donations"
"details commit"
"details lastfm" "details lastfm"
"webrings webrings" "webrings webrings"
"status binkies" "status binkies"
@ -95,6 +96,22 @@ h6 {
.skills { .skills {
grid-area: skills; grid-area: skills;
} }
.commit {
grid-area: commit;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0px;
padding: 5px;
margin: 5px;
}
.commit > *,
.commit > * > * {
padding: 0;
margin: 0;
}
.binkies { .binkies {
grid-area: binkies; grid-area: binkies;
display: flex; display: flex;
@ -112,7 +129,8 @@ h6 {
} }
.logo { .logo {
max-width: 80%; max-width: 80%;
max-height:80%;} max-height: 80%;
}
webring-container { webring-container {
width: unset !important; width: unset !important;
height: unset !important; height: unset !important;
@ -125,6 +143,7 @@ webring-container {
"skills " "skills "
"donations " "donations "
"lastfm" "lastfm"
"commit"
"webrings" "webrings"
"binkies" "binkies"
"blog " "blog "

View file

@ -6,6 +6,7 @@ __TEMPLATE_HEAD__
<script type="module" src="scripts/particles.js"></script> <script type="module" src="scripts/particles.js"></script>
<script type="module" src="scripts/lastfm.js"></script> <script type="module" src="scripts/lastfm.js"></script>
<script type="module" src="scripts/binkies.js"></script> <script type="module" src="scripts/binkies.js"></script>
<script type="module" src="scripts/commit.js"></script>
<link rel="stylesheet" href="assets/style.css"> <link rel="stylesheet" href="assets/style.css">
</head> </head>
@ -95,7 +96,8 @@ __TEMPLATE_HEAD__
</ul> </ul>
</div> </div>
<div class="paper blog" id="root"></div> <div class="paper blog" id="root"></div>
<div class="paper status" id="status"></div> <div class="paper status" id="status">
</div>
<div class="paper binkies"> <div class="paper binkies">
</div> </div>
<div class="paper webrings"> <div class="paper webrings">
@ -112,9 +114,9 @@ __TEMPLATE_HEAD__
src="https://webring.bucketfish.me/embed.html?name=☹️☹️☹️.ovh&lightmode=true"></iframe> src="https://webring.bucketfish.me/embed.html?name=☹️☹️☹️.ovh&lightmode=true"></iframe>
</div> </div>
<div class="paper lastfm" id="lastfm"> <div class="paper lastfm" id="lastfm"></div>
<div class="paper commit" id="commit">
</div> <h1>Latest commit!</h1>
</div> </div>
</body> </body>

28
website/scripts/commit.ts Normal file
View file

@ -0,0 +1,28 @@
import { timeAgo } from "./util";
const git = __GIT_LOG_OUTPUT__;
const date = new Date(git.date);
const commit = document.getElementById("commit");
const a = document.createElement("a");
a.href = `https://git.sad.ovh/sophie/website/commit/${git.commit}`;
const h2 = document.createElement("h2")
h2.innerText = git.message;
a.appendChild(h2);
const p = document.createElement("p");
p.innerText = `${timeAgo(date)} -- ${git.date}`
const p2 = document.createElement("p");
p2.innerText = `commit by ${git.author.replace(/[^ ]*@.*/, "")}`
commit?.appendChild(a)
commit?.appendChild(p)
commit?.appendChild(p2)
// <h1>More binkies + thinliquid's logo!! tysm :3</h1>
//<p>20 minutes ago -- 2024-08-29 22:00:36 GMT+3</p>