npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ipikuka/next-mdx-remote

v2.0.0

Published

It is an opinionated wrapper for the serialize function of the `next-mdx-remote` package that written by hashicorp

Downloads

55

Readme

@ipikuka/next-mdx-remote

NPM version Build npm-typescript License

This package is an opinionated wrapper of the next-mdx-remote.

When should I use this?

The @ipikuka/next-mdx-remote provides a serialize function. The serialize function is an opinionated wrapper of the serialize function of the next-mdx-remote which is a set of light utilities allowing MDX to be loaded within getStaticProps or gerServerSideProps and hydrated correctly on the client.

The plugins used in the @ipikuka/next-mdx-remote comes from @ipikuka/plugins.

@ipikuka/plugins provides remarkPlugins, rehypePlugins, recmaPlugins, and remarkRehypeOptions.

Thanks to @ipikuka/plugins, the markdown/mdx content will support table of contents, containers, markers, aligned paragraphs, gfm syntax (tables, strikethrough, task lists, autolinks etc.), inserted texts, highlighted code fences, code titles, autolink for headers, definition lists etc. in addition to standard markdown syntax like bold texts, italic texts, lists, blockquotes, headings etc.

For other mdxOptions see https://github.com/hashicorp/next-mdx-remote#apis.

Installation

This package is suitable for ESM module only. In Node.js (16.0+), install with npm:

npm install @ipikuka/next-mdx-remote

or

yarn add @ipikuka/next-mdx-remote

Usage

This package is peer dependant with react, react-dom; so it is assumed that you have already installed.

import { MDXRemote } from "@ipikuka/next-mdx-remote";
import { serialize } from "@ipikuka/next-mdx-remote/serialize";

import * as components from "../components/mdxcomponents";

export default function TestPage({ mdxSource }) {
  return (
    <div className="mdx-wrapper">
      <MDXRemote {...mdxSource} components={components} />
    </div>
  );
}

export async function getStaticProps() {
  // the source can be from a local file, database, anywhere
  const source = "Some mdx content with a component <Test />";
  const mdxSource = await serialize(source);

  return { props: { mdxSource } };
}

Options

The @ipikuka/next-mdx-remote serialize function accepts the same options with next-mdx-remote.

All options are optional.

type SerializeOptions = {
  /**
   * Pass-through variables for use in the MDX content
   */
  scope?: Record<string, unknown>;
  /**
   * These options are passed to the MDX compiler.
   * See [the MDX docs.](https://github.com/mdx-js/mdx/blob/master/packages/mdx/index.js).
   */
  mdxOptions?: Omit<CompileOptions, "outputFormat" | "providerImportSource"> & {
    useDynamicImport?: boolean;
  };
  /**
   * Indicate whether or not frontmatter should be parsed out of the MDX. Defaults to false
   */
  parseFrontmatter?: boolean;
};

For example, you can specify the source is markdown md. (Default is MDX mdx).

const source = "Some **bold text** and ==marked text==";
const mdSource = await serialize(source, { mdxOptions: { format: "md" } });

Examples:

Need a playground with single page web application. (PR is wellcome)

Types

This package is fully typed with TypeScript and exposes the types as the official next-mdx-remote does.

Compatibility

It is a Nextjs compatible package.

Security

License

MIT © ipikuka

Keywords

unified remark remark-plugin next-mdx-remote