@seihon/macro

A Babel macro for @seihon/loader

Usage no npm install needed!

<script type="module">
  import seihonMacro from 'https://cdn.skypack.dev/@seihon/macro';
</script>

README

@seihon/macro

npm version download Babel Macro lerna License CircleCI

Seihon【製本】(Bookbinding in Japanese) is a JavaScript toolkit that improves your MDX transformation pipeline. It allows you to quickly transform MDX documents into a collection (like turning codices into book).

More importantly, this toolkit is the last piece of the puzzle that enables code-splitted CMS-less MDX-based static site generation.

@seihon/macro is a babel-macro that transpiles collection<Item>('../example.collection.js') into require('../example.collection.js').

  • It allows you to avoid using require directly in your code.

  • Additionally, this gives you the ability to type check your Seihon collections.

Usage

This is an example of using @seihon/macro alone. For a complete example of the entire Seihon toolkit, please refer to the main README.md.

// src/components/home.jsx
import React from 'react';
import collection from '@seihon/macro';

const posts = collection('../content/posts/collection.config.js');

export default function Blog() {
  return posts.map(({ postId, minRead }) => (
    <PostPreview postId={postId} minRead={minRead} />
  ));
}

Support

This library has been continuously used in many of my personal projects, and is regarded as production-ready. In the foreseeable future, I will continuously maintain and support this library.

Issues and Feedback

Please voice your opinion and report bugs in the issues sections of this GitHub project.

Contributing

You are more than welcome to add more functionalities, improve documentation, fix bugs, and anything you think is needed. The build step is pretty self-explanatory. Please refer to CONTRIBUTING.md for more details.

License

MIT