Skip to content

Vergil1000x/Blog

Repository files navigation

Hello World! 🎉

Welcome to my very first blog post using MDX! I’m thrilled to share my journey into the world of Next.js and all the exciting things you can do with it.

Why MDX is Awesome

So, what’s the deal with MDX? It’s like Markdown’s cooler sibling! MDX lets you mix in React components right alongside your Markdown content, allowing you to create interactive and engaging posts that stand out. This makes your blog more lively and fun!

Getting Started with Next.js

If you haven’t tried Next.js yet, you’re in for a treat! It’s a fantastic framework that makes building React applications a breeze.

Here’s how I set up my Blog project with Remote MDX support:

Here’s How I Did It

  1. Creating the App:

    npx create-next-app@latest blog
  2. Adding MDX Support:

    npm install @next/mdx @mdx-js/loader @mdx-js/react next-mdx-remote
  3. Configuring MDX: I updated my next.config.js to enable MDX processing—easy peasy! Here’s how:

    const withMDX = require("@next/mdx")({
      extension: /\.mdx?$/,
    });
    
    module.exports = withMDX({
      pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
    });
  4. Project Structure: My project structure looks like this:

    your-project
    ├── public               # Public assets (e.g., images, favicon)
    ├── src
    │   ├── app             # Application routes and pages
    │   │   ├── about       # About page
    │   │   │   └── page.tsx # About page component
    │   │   ├── blog        # Blog section
    │   │   │   ├── posts   # Directory for blog posts
    │   │   │   │   ├── post_1.mdx # First blog post in MDX format
    │   │   │   │   └── post_2.mdx # Second blog post in MDX format
    │   │   │   ├── [slug]  # Dynamic routing for blog posts
    │   │   │   ├── loading.tsx # Loading state for blog section
    │   │   │   └── page.tsx # Blog page component
    │   │   ├── favicon.ico  # Favicon
    │   │   ├── globals.css   # Global styles
    │   │   ├── layout.tsx     # Main layout component
    │   │   ├── loading.tsx     # Global loading state
    │   │   └── page.tsx       # Main entry page
    │   ├── components        # Reusable components
    │   │   ├── Footer.tsx    # Footer component
    │   │   └── Header.tsx    # Header component
    ├── .eslintrc.json       # ESLint configuration
    ├── .gitignore            # Git ignore file
    ├── next-env.d.ts        # TypeScript types for Next.js
    ├── next.config.js       # Next.js configuration (CommonJS)
    ├── next.config.mjs      # Next.js configuration (ESM)
    ├── package-lock.json    # Lockfile for dependencies
    ├── package.json         # Project metadata and dependencies
    ├── postcss.config.mjs    # PostCSS configuration
    ├── README.md            # Project documentation
    ├── tailwind.config.ts    # Tailwind CSS configuration
    └── tsconfig.json        # TypeScript configuration

With these steps, I have a fully functional Next.js application that supports MDX and has a well-organized structure!

Tips for Using MDX 🛠️

  • Mix and Match: You can use React components in your MDX files! Feel free to experiment and see how it works for you. If you need guidance, check out the documentation for Next.js MDX.

  • Experiment with Remote MDX: You can also utilize next/mdx to fetch MDX content from a database or other sources. This makes it easy to dynamically connect and retrieve your MDX files. Try it out and see how it enhances your project!


How to Set Up Your Own Blog Project 📦

To install and run the project from my GitHub repository, follow these steps:

Step 1: Clone the Repository

First, clone the repository to your local machine using Git. Open your terminal and run:

git clone https://github.com/Vergil1000x/Blog.git

Step 2: Navigate to the Project Directory

Change into the project directory:

cd Blog

Step 3: Install Dependencies

Install the necessary dependencies using npm (or yarn, if you prefer):

npm install

Step 4: Configure the Project (if necessary)

If your project requires any specific configuration, such as environment variables or additional setup, refer to the README file in the repository. Make sure to update the next.config.js for MDX support if it's not already set up.

Step 5: Run the Development Server

Start the development server:

npm run dev

Step 6: Access the Application

Once the server is running, open your browser and navigate to:

http://localhost:3000

You should see your blog application running!

Additional Notes

  • Ensure you have Node.js installed on your machine. It’s required to run Next.js applications.

  • If you encounter any issues, check for error messages in the terminal and consult the documentation for the relevant packages or frameworks. Or contact me on Discord.


Let’s Connect!

I’d love for you to join me on this adventure! Feel free to explore the source code for this project on GitHub, and let’s learn together!

Thank you for stopping by, and happy coding! ✨