frouo / next-markdown

Markdown Pages for Next.js with 0 effort, dynamic routes and your layout design
https://twitter.com/nextmarkdown
117 stars 5 forks source link

feat: enhance blog-aware rules to handle more use cases (blog, docs...) #5

Closed frouo closed 2 years ago

frouo commented 2 years ago

Purpose

Allow to customize the YYYY-MM-DD rule for given folder.

Thus allowing specified folder to have custom rule to sort content:


pages-mardown/
├ docs/
   ├ feat-A-doc1.md
   ├ feat-A-doc2.md
   ├ feat-B-doc1.md
   ├ feat-B-doc2.md
   ├ feat-B-doc3.md
``

## how to?

Please take example to the function `include` in the NextMarkdownConfig type, where `include` has a default behavior that can be overridden.
frouo commented 2 years ago

Here are the rules we should go for:

Note: having bracket is totally optional (cf. rule 2)

Examples, resulting to the same behavior

brackets
image image

The index.md rendered page will received props:

props: {
  ...
  posts: [
    {
      ...
      nextmd: [docs, get-started]
    },
    {
      ...
      nextmd: [docs, blog-aware]
    },
    {
      ...
      nextmd: [docs, dynamic-routes]
    },
    {
      ...
      nextmd: [docs, table-of-contents]
    },
    {
      ...
      nextmd: [docs, examples]
    },
    {
      ...
      nextmd: [docs, contributing]
    },
  ]

What if I don't want a file to be listed?

Answer: create a folder; cf. rule 2: only files will be listed in the index.md rendered page.

In the following example, /docs/contribution will not be listed in the rendering of /docs

image