GithubHelp home page GithubHelp logo

billykwok / seihon Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 2.38 MB

The last piece of the puzzle enabling code-splitted CMS-less MDX-based static site generation.

Home Page: https://github.com/billykwok/seihon

License: MIT License

JavaScript 18.94% TypeScript 81.06%
mdx-js mdx webpack loader unified remark-plugin javascript static-site markdown frontmatter

seihon's Introduction

SEIHON

Babel Macro lerna codecov 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.

It currently consists of two libraries.

  1. @seihon/loader is a webpack loader that collects frontmatter from all MDX documents and transforms them into one single object. It allows you to statically generate Table of Content, Blog Directory, Project List, or anything that contains a collection of data derived from frontmatter, without manual maintenance. You can even paginate the result using query parameters.

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

In most occasions, you need to use this toolkit together with webpack, @mdx-js/loader, babel-loader and loadable-components in order to build a code-splitted CMS-less MDX-based static site.

Usage

This is an example of a complete usage of the Seihon library. For individual usage, please refer to their own README.md.

Although Seihon makes no assumption about your project structure, it's always easier to explain its usage with one. Take the following structure as an example.

my-site/
  src/
    components/
      home.jsx
      post.jsx
      ...
    content/
      posts/
        introducing-seihon/
          index.mdx
          ...
        effective-javascript/
          index.mdx
          ...
        seihon.config.js
      projects/
        ...
        seihon.config.js
    ...
  webpack.config.js
  ...
// webpack.config.js
// ...
module: {
  rules: [
    {
      test: /seihon\.config\.js$/,
      use: ['babel-loader', '@seihon/loader'],
    },
    // ...
  ];
}
// src/content/posts/introducing-seihon.mdx

---
title: Introducing Seihon
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
// src/content/posts/effective-javascript.mdx

---
title: Effective JavaScript
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
// src/content/{posts,projects}/seihon.config.js
module.exports = {
  transform: (frontmatter, text) => {
    ...frontmatter,
    postId: frontmatter.title
      .replace(/[^0-9a-zA-Z\s]/gi, '')
      .replace(/\s+/gi, '-')
      .toLowerCase(),
    minRead: Math.ceil(text.split(' ').length / 200)
  }
};
// src/components/home.jsx
import React from 'react';
import seihon from '@seihon/macro';

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

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

Configuration

Loader Options

@seihon/loader takes two options, which control the global behaviors.

{
  esModule: true, // boolean - wether to emit the resulting frontmatter array in ES Module syntax
  parallel: 10 // number - the level of parallelism used when reading frontmatters from markdown files
}

The individual seihon.config.js determines how a specific collection of frontmatters is loaded. The filename seihon.config.js is just a convention. It can be changed to any name as you like.

{
  transform: (frontmatter, markdownContent, filePath) => frontmatter, // function - allow custom transformation of frontmatter
  sort: (a, b) => a < b; // function - allow custom sorting of the list of frontmatters
  serialize: {}, // Record<string, data => string> - allow custom serialization of a specific key in the frontmatter
  hook: code => code // function - allow custom transformation of the final code right before emitting
}

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

seihon's People

Contributors

billykwok avatar greenkeeper[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

seihon's Issues

An in-range update of eslint-config-airbnb is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency eslint-config-airbnb was updated from 18.0.1 to 18.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-airbnb is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/parser is breaking the build 🚨

The devDependency @typescript-eslint/parser was updated from 2.19.0 to 2.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for v2.19.1

2.19.1 (2020-02-10)

Bug Fixes

  • eslint-plugin: [unbound-method] blacklist a few unbound natives (#1562) (4670aab)
  • typescript-estree: ts returning wrong file with project references (#1575) (4c12dac)
Commits

The new version differs by 5 commits.

  • 1c8f0df chore: publish v2.19.1
  • 4c12dac fix(typescript-estree): ts returning wrong file with project references (#1575)
  • e9cf734 docs(eslint-plugin): fix typo in readme
  • 10d86b1 docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
  • 4670aab fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-config-prettier is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency eslint-config-prettier was updated from 6.10.0 to 6.10.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-config-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

Commits

The new version differs by 13 commits.

  • a188a3c eslint-config-prettier v6.10.1
  • a5b25ac Fix Windows tests
  • 8126c58 Update readme
  • a91a6a5 Update versions in readme
  • 2a7fa6a Use proseWrap: never for better git diffs
  • b76e316 Recommend running the CLI helper tool using npx
  • 4366d25 Add empty .prettierrc to help editor extensions
  • 538dbb5 Use less of eslint-plugin-prettier
  • 7dffee0 Format markdown files with Prettier
  • 2a5b854 Update npm packages, including Prettier 2.0 changes
  • 855185f Remove TravisCI
  • 83705e8 Disable linebreak-style in test for Windows support
  • b6559bf Add GitHub Actions

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of babel-loader is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency babel-loader was updated from 8.0.6 to 8.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

babel-loader is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for 8.1.0
Commits

The new version differs by 18 commits.

  • 3ff9926 8.1.0
  • 0817bb6 Bump deps for audit (#834)
  • ecb2b02 Bump acorn from 6.3.0 to 6.4.1 (#828)
  • 13a8238 feat: expose webpack target via babel caller (#826)
  • b568420 Merge pull request #814 from nicolo-ribaudo/tla
  • 1c35731 Update src/injectCaller.js
  • 5f55638 Add schema validation (#822)
  • 8b47312 Merge pull request #821 from PatNeedham/docs/contributing-typo
  • a967311 docs(contributing): fix typo
  • 758d4b5 docs(readme): fix typo (#818)
  • 8a0a25a Add supportsTopLevelAwait to caller
  • 15df92f chore: Do not run node 6 in appveyor
  • 26d1676 chore: Upgrade more dev dependencies
  • 26aa687 chore: Update some dev dependencies
  • a961168 Bump eslint-utils from 1.3.1 to 1.4.2 (#806)

There are 18 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of react is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


There have been updates to the react monorepo:

    • The devDependency react was updated from 16.13.0 to 16.13.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the react group definition.

react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/prettier is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency @types/prettier was updated from 1.19.0 to 1.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 2.19.0 to 2.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for v2.19.1

2.19.1 (2020-02-10)

Bug Fixes

  • eslint-plugin: [unbound-method] blacklist a few unbound natives (#1562) (4670aab)
  • typescript-estree: ts returning wrong file with project references (#1575) (4c12dac)
Commits

The new version differs by 5 commits.

  • 1c8f0df chore: publish v2.19.1
  • 4c12dac fix(typescript-estree): ts returning wrong file with project references (#1575)
  • e9cf734 docs(eslint-plugin): fix typo in readme
  • 10d86b1 docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
  • 4670aab fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @mdx-js/loader is breaking the build 🚨

The devDependency @mdx-js/loader was updated from 1.5.1 to 1.5.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@mdx-js/loader is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for v1.5.2

• Misc. dependency updates

Commits

The new version differs by 50 commits.

  • 442c11d v1.5.2
  • 8de5960 Ignore cache dir (#875)
  • 1137692 chore(deps): update dependency typescript to v3.7.3 (#874)
  • c8e494c chore(deps): update dependency eslint-plugin-import to v2.19.1 (#872)
  • a662454 chore(deps): update dependency eslint-plugin-prettier to v3.1.2 (#873)
  • 53aafd4 chore(deps): update dependency core-js to v2.6.11 (#871)
  • 05c4a74 chore(deps): update dependency babel-plugin-macros to v2.8.0 (#870)
  • 8a12e26 chore(deps): update dependency @pkgr/rollup to v0.8.6 (#869)
  • bc0647d fix(deps): update dependency unist-util-visit to v2.0.1 (#861) (#867)
  • e67c1da fix(deps): update dependency unist-util-visit to v2.0.1 (#861)
  • 8c19b85 fix(deps): update dependency unified to v8.4.2 (#860)
  • 363513c chore(deps): pin dependencies (#858)
  • f063964 doc(readme) fix example (#862)
  • 2d18f40 fix(deps): update dependency remark-parse to v7.0.2 (#859)
  • cf74138 perf: move all devDependencies to root package.json, prettier all files except .md/.mdx temporarily (#857)

There are 50 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.