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

I'm working on a static site generator (Raise) that's taking a bunch of lessons from one of my previous projects, a testing library called Distilled[0].

The development philosophy with Distilled was to have a very, very small but flexible API, and to basically try to get out of your way. Distilled takes the view that some parts of testing are a lot easier than people think, so it explicitly doesn't do those things. It doesn't give you a test harness out of the box, it doesn't give you a `beforeEach`, stuff like that. It gives you a very solid, very predictable base that you can very quickly morph in different directions. I've been using Distilled for ~2 years at this point, and it's been a mild revolution in how I approach testing.

So the philosophy with Raise is very similar. With Raise, there are no built-in transpilers or templating engines, there is no CLI. I expect you to do whatever text transformation you need yourself, either manually or through a 3rd-party library. What Raise does do is make it very easy to recursively pipe directories through transform functions, and very easy to build complicated transforms.

So if you want to compile a bunch of markdown files:

  await Raise({
    input: './source',
    output: './public',
    transform: {
      '**/*.md': async (info) => ({
        [`${info.filename}.html`]: marked(await info.contents())
      })
    }
  });
And you can also do fun things like recursively return transforms, which makes Raise really easy to extend and adapt to different projects. So for example, if your sitemap was being managed by a CSV file or something:

  await Raise({
    input: './source',
    output: './public',
    transform: {

      /* structure: "page_name", "page_location" */
      'pages.csv': async (info) => {
         let pages = parse(await info.contents('utf8'));
         return pages.reduce((result, page) => {
           result[page[1]] = async (info) => ({
              [page[0]]: marked(await info.contents())
           })
         }, {});
       }
    }
  });
There are a few other cool tricks you can pull with it, but they're hard to explain in small code samples. But you're not getting any transforms for free, and I'm not trying to intuit anything about the structure of your site. There's no magical behavior. But what you get in return for that is an API that is extremely consistent, extremely predictable, very easy to learn, and very easy to adapt to novel situations.

Still a work in progress, but I should be done with the last few chores for the alpha within the next few days, at which point I'm going to start testing it out by converting some of my own sites to use this as the builder.

[0]: https://distilledjs.com/



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

Search: