Easy way to migrate your existing page router code or content directory code to the app router file convention in one click with nodejs script #4100
jeevankc17
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Script to Translate All
.mdx
Files from thecontent
Directory to theapp
DirectoryIntroduction
If you felt uncomfortable working with Nextra 4.x releases that comes with two Top-Level Folders i.e. app directory and content directory.
I will explain how to create a script in Node.js that reads all
.mdx
files from acontent
directory and converts them to the file convention that works withapp
directory.We'll use Node.js and its built-in
fs
(File System) module to read, write, and process these files.Prerequisites
Before getting started, ensure you have the following:
content
directory containing.mdx
files that need conversion.Workflow Overview
The script will create page.mdx file and copy all the code from your whatever_name.mdx file then then put the page.mdx file to the whatever_name folder and delete the whatever_name.mdx file.
Writing the Script
To automate this task, we’ll create a script using Node.js. The script will:
Step-by-Step Script
Beta Was this translation helpful? Give feedback.
All reactions