GithubHelp home page GithubHelp logo

shadcn / next-mdx Goto Github PK

View Code? Open in Web Editor NEW
190.0 2.0 14.0 5.42 MB

next-mdx provides a set of helper functions for fetching and rendering local MDX files. It handles relational data, supports custom components, is TypeScript ready and really fast.

Home Page: http://next-mdx.org

License: MIT License

JavaScript 10.80% TypeScript 86.22% Shell 2.98%
nextjs nextjs-plugin mdx mdx-js

next-mdx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

next-mdx's Issues

Filtering documents by relationship

I have two types of nodes: Post and Snippet. I would like a Post to be composed of multiple snippets (which Snippet it belongs to is defined in the Snipper's front matter), while retaining the ability to refer to a Snippet on its own.

Is it possible to call getAll*Nodes('snippet') from the Post document and only have it return the Snippets that belong to the post?

rendering images in mdx posts

I have tried to publish .mdx posts with images but it doesn't seem to work. I tried inserting this:

<Image src={/images/placeholder.png} alt={image alt text} layout="fill"  />

Any ideas how to post images?
Thanks

getMdxNode's context type is incompatible with nextjs's

For this code:

import { GetStaticProps } from 'next';
export const getStaticProps: GetStaticProps = async (context) => {
    const post = await getMdxNode('post', context);

    if (!post) {
        return {
            notFound: true,
        };
    }

    return {
        props: {
            post,
        },
    };
};

TypeScript is emitting this warning for L3:

TS2345: Argument of type 'GetStaticPropsContext<ParsedUrlQuery>' is not assignable to parameter of type 'string | GetStaticPropsContext<Dict<string[]>>'.  
Type 'GetStaticPropsContext<ParsedUrlQuery>' is not assignable to type 'GetStaticPropsContext<Dict<string[]>>'.
Type 'ParsedUrlQuery' is not assignable to type 'Dict<string[]>'. 
Index signatures are incompatible.
Type 'string | string[] | undefined' is not assignable to type 'string[] | undefined'.
Type 'string' is not assignable to type 'string[] | undefined'.

Add support for next-mdx.config.js

Replace next-mdx.json with next-mdx.config.js.

TBH I can't figure out how to make this work (probably limited to using micribundle?).

If anyone want to take a stab at this, that'd be awesome.

Handling Next localization with next.config.js

Is there a workaround for handling locales? I get 404 when trying to get to the blog with a locale.

http://localhost:3000/blog/post-slug will return the post correctly but http://localhost:3000/es-MX/blog/post-slug will return 404.

I don't mind if it returns the same content, I just want the post to be rendered as the same if the url has the locale.

Render inlineCode and code

is there an option to separate code and inlineCode in the components?
Here's my code:

const components = { h1: ({ children }) => { return <Heading as="h1">{children}</Heading>; } code: ({ children }) => { return <p sx={{ color: "blue", background: 'red' }}>{children}</p>; }, inlineCode: ({ children }) => { return <p sx={{ color: "red", background: 'yellow' }}>{children}</p>; } };

const content = useHydrate(doc, { components: components, });

Add reading time, word count

Fantastic library, I'm really enjoying the simplicity it brings to building an mdx-powered site with relational data. It would be useful to add reading-time and wordCount parameters to the frontmatter. Would you accept a PR for this? Looking at the source, I believe it would be easiest to add these parameters in get-nodes.ts in the getFileData() function.

Multiple slugs for the same document

Would this be possible? I am fine with just using the main slug (i.e. the filename) to reference a document internally but I would like multiple slugs to resolve to the same file.

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.