Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for Next.js app router exports #34

Merged
merged 6 commits into from
Aug 16, 2023

Conversation

bradlc
Copy link
Contributor

@bradlc bradlc commented Aug 8, 2023

Ref: markdoc/markdoc#416, markdoc/markdoc#418

This PR adds support for specifying the metadata and revalidate exports when using app router:

---
nextjs:
  metadata:
    title: Lorem ipsum
    description: Lorem ipsum dolor sit amet
  revalidate: 60
---

Closes markdoc/markdoc#418
Closes markdoc/markdoc#416

Copy link
Contributor

@mfix-stripe mfix-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradlc I'd like to group all the Next.js specific items under a single key, as you suggested above. I was thinking the key could be called next.js or nextjs, just to disambiguate with the work "next".

What do you think?

@bradlc bradlc changed the title Add support for Next.js metadata export Add support for Next.js app router exports Aug 9, 2023
@bradlc
Copy link
Contributor Author

bradlc commented Aug 9, 2023

Makes sense! I've updated the PR to include all exports that I could find under a nextjs key.

Export names come from:

Let me know if you have any additional feedback! 🤙

Copy link
Contributor

@mfix-stripe mfix-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bradlc! Just a couple comments

src/loader.js Outdated
]
const nextjsExportsCode = nextjsExports
.map((name) => {
return `export const ${name} = frontmatter.nextjs?.${name};`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpaul-stripe WDYT about using the nextjs frontmatter key to allow users to specify Next.js specific features (like metadata and revalidate)

Alternative keys:

  • next.js
  • config / options (higher chance for collisions)

I think I like next.js best (personally)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nextjs is good.

bradlc and others added 3 commits August 10, 2023 09:23
Co-authored-by: Mike Fix <62121649+mfix-stripe@users.noreply.github.com>
Co-authored-by: Mike Fix <62121649+mfix-stripe@users.noreply.github.com>
'revalidate',
]
const nextjsExportsCode = nextjsExports
.map((name) => `export const ${name} = frontmatter.nextjs?.${name};`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpaul-stripe WDYT about using the nextjs frontmatter key to allow users to specify Next.js specific features (like metadata and revalidate)

Alternative keys:

  • next.js
  • config / options (higher chance for collisions)

I think I like next.js best (personally)

@mfix-stripe mfix-stripe merged commit 42f67e3 into markdoc:main Aug 16, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants