feat: initial commit

This commit is contained in:
nullishamy 2025-06-03 18:42:27 +01:00
commit 8805505864
Signed by: amy
SSH key fingerprint: SHA256:WmV0uk6WgAQvDJlM8Ld4mFPHZo02CLXXP5VkwQ5xtyk
6 changed files with 217 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.direnv/

61
flake.lock generated Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1743550720,
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1748460289,
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1743296961,
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

31
flake.nix Normal file
View file

@ -0,0 +1,31 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
];
};
devShells.default = pkgs.mkShell {
env = {
};
packages = with pkgs; [
racket
];
};
};
};
}

30
out.html Normal file
View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<head class="">
<style class="">
.title {
font-size: xxx-large;
}
.subtitle {
font-size: xx-large;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
}
</style>
</head>
<html>
<body class="content">
<h1 class="title">rssg</h1>
<p class="">this is a little demo for my Racket based SSG</p>
<section class="">
<h2 class="subtitle">my first subsection</h2>
<p class="">this text appears inside the subsection :D</p>
</section>
</body>
</html>

93
src/index.rkt Normal file
View file

@ -0,0 +1,93 @@
#lang racket
(define doctype "<!DOCTYPE html>")
(define nl "\n")
(define (flatten lst)
(cond
[(null? lst) '()]
[(list? (car lst)) (append (flatten (car lst)) (flatten (cdr lst)))]
[else (cons (car lst) (flatten (cdr lst)))]))
(define (with-element elem content #:nl-char [nl-char ""] #:class [classes '()])
(string-append "<" elem " class=\"" (string-join classes " ") "\"" ">" nl-char content nl-char "</" elem ">"))
(define (title content)
(lambda () (with-element "h1" content #:class '("title"))))
(define (subtitle content)
(lambda () (with-element "h2" content #:class '("subtitle"))))
(define (paragraph content)
(lambda () (with-element "p" content)))
(define (css styles)
(lambda () (with-element "style" styles)))
(define (style url)
(lambda () (string-append "<link href=\"" url "\" rel=\"stylesheet\" />")))
(define (make-subsection elem children)
(lambda ()
(with-element elem (string-join (map (lambda (fn) (fn)) children) nl) #:nl-char nl)))
(define head
(lambda parts
(make-subsection "head" parts)))
(define section
(lambda parts
(make-subsection "section" parts)))
(define make-document
(lambda parts
(define head-proc (list-ref parts 0))
(define body-procs (drop parts 1))
(define strings
(flatten
(list doctype
(head-proc)
"<html>"
"<body class=\"content\">"
(map (lambda (fn) (fn)) body-procs)
"</body>"
"</html>")))
(list (lambda ()
(string-join strings nl)))))
(define (render elements)
(string-join (map (lambda (fn) (fn)) elements) nl))
(define basic-theme "
.title {
font-size: xxx-large;
}
.subtitle {
font-size: xx-large;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
height: 100%;
}
")
(define document
(render (make-document
(head
(css basic-theme))
(title "rssg")
(paragraph "this is a little demo for my Racket based SSG")
(section
(subtitle "my first subsection")
(paragraph "this text appears inside the subsection :D")))))
(display document)