timlrx / tailwind-nextjs-starter-blog

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.
https://tailwind-nextjs-starter-blog.vercel.app/
MIT License
8.56k stars 1.99k forks source link

How to be compatible with md files in the latest version, v2.0.1 #703

Closed ita-code closed 9 months ago

ita-code commented 1 year ago
image
timlrx commented 1 year ago

I recommend just renaming the md files to mdx. There would be more correct as the plugins are mostly meant to work with mdx files.

Alternatively, if you do you are just using strictly md, you can modify the contentType and filePathPattern in defineDocumentType. Note that certain plugins e.g. remarkImgToJsx might not be compatible and should be remove.

ita-code commented 1 year ago

Thank you. I know what to do.

timlrx commented 11 months ago

@ita-code any reasons for reopening this issue?

stepcellwolf commented 11 months ago

@timlrx is there possibility to use both contentTypes, md and mdx? I tried to adjust the settings in but it is still not working by adding md: filePathPattern: 'blog/**/*.mdx','blog/**/*.md', contentType: 'mdx','md',

Any workaround to this problem? I have > 150 md files.

timlrx commented 11 months ago

@timlrx is there possibility to use both contentTypes, md and mdx? I tried to adjust the settings in but it is still not working by adding md: filePathPattern: 'blog/**/*.mdx','blog/**/*.md', contentType: 'mdx','md',

Any workaround to this problem? I have > 150 md files.

I think you can glob the file path patterns but there might be further issues with parsing iirc. Easiest way would be renaming. Here's a script generated from gpt that might help:

const { readdir, rename } = require('fs').promises;
const path = require('path');

async function renameMdToMdx(directoryPath) {
  try {
    const files = await readdir(directoryPath);
    for (const file of files) {
      if (file.endsWith('.md')) {
        const oldFilePath = path.join(directoryPath, file);
        const newFileName = file.replace('.md', '.mdx');
        const newFilePath = path.join(directoryPath, newFileName);
        await rename(oldFilePath, newFilePath);
        console.log(`Renamed ${file} to ${newFileName}`);
      }
    }
  } catch (err) {
    console.error('Error:', err);
  }
}

// Usage example
const directoryPath = '/path/to/your/directory';
renameMdToMdx(directoryPath);