From 8805505864e46bcd33851cf3b99eecf1f8c6a00c Mon Sep 17 00:00:00 2001 From: nullishamy Date: Tue, 3 Jun 2025 18:42:27 +0100 Subject: [PATCH] feat: initial commit --- .envrc | 1 + .gitignore | 1 + flake.lock | 61 +++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++++ out.html | 30 +++++++++++++++++ src/index.rkt | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 217 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 out.html create mode 100644 src/index.rkt diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00c1844 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv/ \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e94c4fc --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d2af933 --- /dev/null +++ b/flake.nix @@ -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 + ]; + }; + }; + }; +} diff --git a/out.html b/out.html new file mode 100644 index 0000000..25d1a86 --- /dev/null +++ b/out.html @@ -0,0 +1,30 @@ + + + + + + +

rssg

+

this is a little demo for my Racket based SSG

+
+

my first subsection

+

this text appears inside the subsection :D

+
+ + \ No newline at end of file diff --git a/src/index.rkt b/src/index.rkt new file mode 100644 index 0000000..907c2a9 --- /dev/null +++ b/src/index.rkt @@ -0,0 +1,93 @@ +#lang racket + +(define doctype "") +(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 "")) + +(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 ""))) + +(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) + "" + "" + (map (lambda (fn) (fn)) body-procs) + "" + ""))) + + (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)