Giter VIP home page Giter VIP logo

amdx's Introduction

AMDX

Accelerated MDX

Features

  • MDX to AMP

  • AMP Friendly Output

  • Opinionated remark settings

    • Highlight with refract
    • frontmatter
    • Gen amp-img from img with {amp: true} config
    • Gen amp-mathml from $$ ~ $$
  • Rich parser and thin runner to preprocess

  • Worker Friendy: Compile to pure JSON to postMessage

AMDX document example

Use .mdx extension to highlight

<!-- foo.mdx -->

import Bar from "./bar"

# Hello from Foo

<Bar />
<!-- bar.mdx -->

import Bar from "./bar"

# Bar

render foo.mdx (with amdx-loader/rollup-plugin-amdx)

import React from "react";
import ReactDOM from "react-dom/server";
import Foo from "./foo.mdx";

const str = ReactDOMServer.renderToString(<Foo />);
console.log(str);

packages

  • amdx-loader: webpack-loader
  • amdx: parser and compiler by remark
  • amdx-runner: runner for parsed json
  • amdx-cli: amdx cli tools
  • rollup-plugin-amdx: rollup plugin

AMDXG: Static Site generator with next.js

  • amdxg-docs: Doc by amdx on next.js
  • amdxg-components: ssg components
  • amdxg-cli: ssg components

CLI

# install
$ npm install amdx-cli -g

webpack loader

module.exports = {
  module: {
    rules: [
      // add this rule
      {
        test: /\.mdx?/,
        loader: "amdx-loader",
      },
    ],
  },
};

rollup

// rollup.config.js
import { amdx } from "rollup-plugin-amdx";
export default {
  // ...
  plugins: [amdx()],
};

API

import React from "react";
import ReactDOM from "react-dom";

import { compile } from "amdx-runner";
import { parse } from "amdx";

const ast = parse(`# hello`);

function App(props) {
  return const el = compile(ast, {
    props,
    components: {},
    h: React.createElement,
    Fragment: React.Fragment
  });
}

ReactDOM.render(<App />, document.querySelector("#main"));

TODO

  • title
  • amp-img
  • Social Share button
  • CLI Scaffolding
  • Google Analytics
  • Header
  • Fix css on export
  • amdx-runner: amp option
  • amdxg Support styled-components
  • amdxg AMP Install Service Worker
  • amdxg Refactor layout css
  • amdxg amp-img fixed height
  • compiler: heading slug
  • compiler: toc
  • amdxg Fix css
  • amdxg Support amp-social-share
  • amdxg amdxg-cli
  • parser: Support amp-mathml
  • CI
  • amdxg Gen git history
  • amdxg Link to GitHub PR
  • amdxg-components: create
  • amdxg Render mdx on pages/*.mdx => auto gen /docs by getStaticProps
  • amdxg Gen RSS
  • Rename to something => amdx
  • amdxg amp-script compiler or new:script boilerplate
  • amdxg clickable anchor
  • Fix prism
  • Fix amp-img
  • Next 9.4 ssg fallback mode

LICENSE

MIT

amdx's People

Contributors

1000ch avatar mizchi avatar mottox2 avatar sadnessojisan avatar tgfjt avatar yamanoku avatar

Watchers

 avatar

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.