question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fractal as static site generator and/or plugin?

See original GitHub issue

Forgive me if this way off-base, but re: modularity discussed in #197, you might consider either supporting plugins for a popular static site generator (via a common API) or essentially turning Fractal into a static site generator plugin that can be run in isolation. That way, Fractal could leverage an ecosystem of plugins that already exist (e.g. for compiling Sass or rendering Markdown) rather than needing to build and support its own.

For instance, Metalsmith does one thing well that (to my eye, at least) appears to map directly to at least one part of Fractal: it walks a directory and creates an in-memory “file system” object with both site- and file-specific metadata, then provides a plugin API for modifying any/all of them. In practice, this would mean replacing fs.js/ffs with Metalsmith and rewriting the core to work with a its file system object and data objects. Fractal’s “core” Metalsmith plugin could then either just build the component data structure, or load the theme specified in the options and tell it to render:

// options here can come either directly from the JS API or
// from the dependent module's package.json
modul.exports = function plugin(options) {
  return function fractalize(files, metalsmith, done) {
    const metadata = metalsmith.metadata();
    const opts = Object.assign({}, metadata.fractal, options);
    const fractal = metadata.fractal = new Fractal(opts);
    return async.eachSeries(
      Object.keys(files),
      // this is a fictional API, but something like this would need to exist
      (path, next) => fractal.addFile(path, files[path], next),
      // finally, reconcile all the files into their respective components
      error => error ? done(error) : fractal.build(done)
    );
  };
};

The Fractal CLI could then use other plugins to do the watching, serving w/live reloading, etc.

Metalsmith is just an example—there are a number of similar frameworks, each with their own ecosystems. There’s obviously a good deal of risk involved in hitching Fractal to the success of another framework, but I think it might be worth it if you can leverage the tools and talents of an existing community.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ismaycommented, Feb 3, 2017

@micahgodbolt Btw, metalsmith-in-place v2 was just released, which is in my opinion better suited for templating than layouts in most use-cases. It uses jstransformers and can easily be extended with a custom rendering engine if needed. Might be useful.

1reaction
micahgodboltcommented, Feb 2, 2017

I’m giving this a try in that I’m creating a new site that uses fractal templates to drive metalsmith’s layout files. Basically setting partials directory as fractal/components and using {{> component/component }} to pull templates in.

I did run into one issue with metalsmith-layouts where non template files in the component folder were causing problems.

Here’s the current proposed fix for that.

https://github.com/superwolff/metalsmith-layouts/pull/116

I"ll be sure to keep everyone updated on my progress of combining the two.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Staatic – Static Site Generator - plugin
Powerful Crawler to transform your WordPress site quickly. Supports multiple deployment methods, e.g. Netlify, AWS (Amazon Web Services) S3 or S3-compatible ...
Read more >
About
Naming shifted to WP Static Site Generator, as people were growing aware of what a static site generator actually was. This was still...
Read more >
Systems under study: Top: The generator for the fractal ...
This study investigated the effects of the absorption area and location on low-frequency noise control in typical dwelling layouts for different room connection ......
Read more >
Static site generators
I've been looking for a decent static site generator to build a simple, 10-page-or-so documentation site, and I'm failing.
Read more >
Lume SSG Handbook – How to Create a Static Blog with ...
js plugin support; You can deploy with Netlify, Vercel, GitLab Pages, and the GitHub page. How Does Lume Compare to Other Static Site...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found