https://github.com/mujtaba-io/c-macro-static-site-generator
Static site generator, that uses C preprocessor syntax.
https://github.com/mujtaba-io/c-macro-static-site-generator
c-macros c-preprocessor static-site static-site-generator static-website webdevelopment
Last synced: about 1 year ago
JSON representation
Static site generator, that uses C preprocessor syntax.
- Host: GitHub
- URL: https://github.com/mujtaba-io/c-macro-static-site-generator
- Owner: mujtaba-io
- License: mit
- Created: 2025-01-25T15:19:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-25T15:52:18.000Z (over 1 year ago)
- Last Synced: 2025-01-25T16:24:18.720Z (over 1 year ago)
- Topics: c-macros, c-preprocessor, static-site, static-site-generator, static-website, webdevelopment
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Static Site Generator - C Preprocessor Syntax
I made this as a quick solution to my unique problem. Although my problem could be solved easily using existing frameworks, but I wanted extremely fast solution requring no setup. So i made a C-macros syntax static site generator.
I usaully make games on [game idea](https://gameidea.org), you can find my work there. Thank you for coming here!
# Usage Examples
In a.html:
```html
#define header(title, subtitle) (
{title}
{subtitle}
)
```
In b.html:
```html
#include <./a.html>
header(My Hehe Title, My Good Subtitle)
#define card(image, title, text) (
{title}
{text}
)
```
After that, run `static_site_generator_machine.py` file. It will create a `build/` folder with a generated website. The other file, `static_site_generator.py` is a layer on top of previous file, that automates the process of re-building as soon as changes have been made to the file. So if u need automated solution, just run the latter file and everything will be auto-generated on save, from the current directory.
# Issues
1. File paths are not resolved in generated site. So you have to put all your assets in `assets/` folder, otherwise issues may arise if during building, the contents of components are copied to other files present in another levels in system directory. Then references such as `./myimage.png` might introduce invalid path as now, the current directory is the directory of another component where this component is `#included`.
2. I have not tested `#ifdef`, `#ifndef`, `#else`, `#endif`, `#undef` etc.
# Other Examples
We declare a component using `#define` like this:

In the above code, the parameters values will be replaced with passed value.
Then we use it like this:

There is more we can do. Basically, most of C proprocessor is implemented, but there can be some issues in conditinoal thing such as `#ifndef`.