frouo / next-markdown Goto Github PK
View Code? Open in Web Editor NEWMarkdown Pages for Next.js with 0 effort, dynamic routes and your layout design
Home Page: https://twitter.com/nextmarkdown
Markdown Pages for Next.js with 0 effort, dynamic routes and your layout design
Home Page: https://twitter.com/nextmarkdown
At the time of writing, next-markdown support nextjs "catch all routes", meaning you need to add a [...nextmd].js
in your pages and create an index.js
for the home page.
We want to create a website (including the home page!) with markdown. To allow creating home page we need to use "optional catch all routes".
next-markdown should work with [[...nextmd]].js
Support MDX files
For example, support such tree:
pages-mardown/
├ about.mdx
├ this/is/an/example.mdx
Allow developers to build such a page with next-markdown:
cf. https://chakra-ui.com/guides/integrations/with-storybook
List every files when rendering index.md. Props should look like:
{
...
html: string,
nextmd: [...],
files: [
{
...
html: string,
nextmd: [..., ...],
},
...
]
}
This can be actually achieved with files[n-1]
and files[n+1]
.
List markdown content headings + add anchors
Please provide an example in examples/
.
[x] Maybe we should rename posts
attribute. It is misleading since it's not asked to be a "blog post" (as we can see, it can also achieve documentation purpose) => done, posts
has been renamed to files
, cf. #5
Please, help.
Right now I have no proper solution:
npm link
but, for every changes in next-markdown/src/index.ts
, I need to execute cd examples/blogging && rm -rf node_modules/next-markdown && npm link
. Very painful.next-markdown/src/index.ts
and use it locally in an example, so when I am done, I copy/paste back to next-markdown/src
. Very painful and ugly...next-markdown
function (eg. export getNextmdFromFilePath = (..)=>{..}
) but import { getNextmdFromFilePath } from '../';
in file __tests__/index.test.ts
failed with error Module '"../index"' has no exported member 'getNextmdFromFilePath'
I don't have the time (and knowledge yet) to setup properly the project this way:
next-markdown/src/index.ts
changes, tests are rannext-markdown/src/index.ts
changes, the project updatesnext-markdown/src/utility.ts
the published npm library does not work (module not found)Any help is much than appreciated 🙏
In some circumstances, you likely want to use subfolders to classify your markdown files. For example when writing docs.
So you want a way to bypass the default next-markdown
dynamic routes.
✋ default dynamic routes MUST remain because it covers 99% of use cases. We all love how nextjs works with
/pages
. . Eg:path/to/projects.md
will match/path/to/project
.
We could have a .nextmd.config.json
file at the root of a given folder to bypass how next-markdown
will consider this folder's subfolders.
# .nextmd.config.json
{
"flatten": ["examples", "features"]
}
Tell me what you think in comment. Thanks
Split the lib in several parts
npm install @nextmarkdown/core
: contains everything but the markdownToHtml logic (commonjs lib)npm install @nextmarkdown/markdown-to-html
: will contain all the logic to convert markdown to html with remark / rehype plugins dependencies (esm module lib because rehype-stringify is ESM only).npm install @nextmarkdown/mdx
: will contain the next-mdx-remote logic.Finally npm install next-markdown
would install, by default, both @nextmarkdown/core and @nextmarkdown/markdown-to-html so it is really easy to get started with next-mardown + covers 80% of the usage cases.
hello:1 GET http://localhost:3000/hello 500 (Internal Server Error)
index.js?20a9:314 Uncaught at Object.next-markdown (file:///Users/kr.mao/Workspace/codesdancing/.next/server/pages/[...nextmd].js:32:1)
at webpack_require (file:///Users/kr.mao/Workspace/codesdancing/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///./src/pages/[...nextmd].jsx:8:71)
at Function.webpack_require.a (file:///Users/kr.mao/Workspace/codesdancing/.next/server/webpack-runtime.js:106:13)
at eval (webpack-internal:///./src/pages/[...nextmd].jsx:1:21)
at Object../src/pages/[...nextmd].jsx (file:///Users/kr.mao/Workspace/codesdancing/.next/server/pages/[...nextmd].js:22:1)
at webpack_require (file:///Users/kr.mao/Workspace/codesdancing/.next/server/webpack-runtime.js:33:42)
at webpack_exec (file:///Users/kr.mao/Workspace/codesdancing/.next/server/pages/[...nextmd].js:52:39)
at (file:///Users/kr.mao/Workspace/codesdancing/.next/server/pages/[...nextmd].js:53:28)
at Object. (file:///Users/kr.mao/Workspace/codesdancing/.next/server/pages/[...nextmd].js:56:3)
getNodeError @ nodeStackFrames.js?aca3:40
eval @ index.js?20a9:313
setTimeout(异步)
_callee$ @ index.js?20a9:301
tryCatch @ runtime.js?96cf:63
invoke @ runtime.js?96cf:294
eval @ runtime.js?96cf:119
asyncGeneratorStep @ index.js?20a9:28
_next @ index.js?20a9:46
Promise.then(异步)
asyncGeneratorStep @ index.js?20a9:37
_next @ index.js?20a9:46
eval @ index.js?20a9:51
eval @ index.js?20a9:43
_initNext @ index.js?20a9:363
initNext @ index.js?20a9:366
eval @ next-dev.js?3346:38
./node_modules/next/dist/client/next-dev.js @ main.js?ts=1646807645629:600
options.factory @ webpack.js?ts=1646807645629:685
webpack_require @ webpack.js?ts=1646807645629:37
webpack_exec @ main.js?ts=1646807645629:1399
(匿名) @ main.js?ts=1646807645629:1400
webpackJsonpCallback @ webpack.js?ts=1646807645629:1268
(匿名) @ main.js?ts=1646807645629:9
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.