Skip to content

Help running a post processing step #424

@0xQilin

Description

@0xQilin

Hi team,

I'm trying to pull out a list of IDs that are within my MDX which will match the regex of const TWEET_RE = /<StaticTweet\sid="[0-9]+"\s\/>/g; that I can then use to perform getStaticProps.

Mainly trying to follow this specific tutorial : https://blog.maximeheckel.com/posts/static-tweets-with-mdx-nextjs/

I was wondering if there's an easy way to modify the makeSource config folder so that I can simply map over the individual file contents within my target folder to extract these IDs.

This is my existing makeSource config.

export default makeSource({
  contentDirPath: "posts",
  documentTypes: [Post],
  mdx: {
    rehypePlugins: [
      [
        rehypePrettyCode,
        {
          // theme: "github-dark",
          theme: JSON.parse(readFileSync(themePath, "utf-8")),
          onVisitLine(node: any) {
            // Prevent lines from collapsing in `display: grid` mode, and allow empty
            // lines to be copy/pasted
            if (node.children.length === 0) {
              node.children = [{ type: "text", value: " " }];
            }
          },
          onVisitHighlightedLine(node: any) {
            node.properties.className.push("line--highlighted");
          },
          onVisitHighlightedWord(node: any) {
            node.properties.className = ["word--highlighted"];
          },
        },
      ],
    ],
  },
});

Thank you so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions