Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wrote my static site generator, too. It is a lot of fun, and much more powerful for my specific use case than any other around (and probably would fail miserably for any other use case). It took 2-3 days and I regret nothing.

There are some novel things though, like, I use markdown files, but separate sections with ``` so I can use different inputs like ```MD for markdown, or ```JSON for pure JSON data, or ```PHP for PHP code. The VS Code highlights the portion of the code correctly, so I can work on many formats/languages on the same page. The .md file looks like this:

   ```INI META
   includes = docs/index.html.md menu menuTop
   title = Theme
   base = docs/docs.html
   slug = theme
   ```

   ```JSON menu
   [
       { "label": "Demo", "url": "/demo/features" },
       { "label": "Try it!", "url": "/try.html?d=/data/try.json" },
       { "label": "Docs", "url": "/docs" }
   ]
   ```

   ```MD BODY
   # Customize the story
   
   Below are the parameters to customize the style of the story.
   ```   
Then I use a PHP script to serve the content live when in development (no compilation, very fast) and a deploy script to generate the HTML files and upload to AWS S3. Works perfectly.


Cool but why not just use regular MD with YAML front matter? I don't find that JSON readable at all, comparatively, and that INI isn't any better than the YAML version.

   ---
   includes: docs/index.html.md menu menuTop
   title: Theme
   base: docs/docs.html
   slug: theme
   menu:
    - label: Demo
      url: /demo/features
    - label: Try it!
      url: /try.html?d=/data/try.json
    - label: Docs
      url: /doc
   ---
   
   # Customize the story
   
   Below are the parameters to customize the style of the story.
And… PHP in a MD file?


The MD file is just for information, and I want to consume this information in different forms. The MD file is just to highlight the code correctly on VS Code on a single file. The PHP script interprets each section and processes it accordingly. This way I am not limited to markdown.

For example, for documentation, I use markdown, but for the website, that I want to control the layout better, I use JSON only, and when I need to create complex operation (as a consult to an external database), I use PHP. The markdown is very limiting, this was the motivation to create my own.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: