Closed ita-code closed 9 months 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.
Thank you. I know what to do.
@ita-code any reasons for reopening this issue?
@timlrx is there possibility to use both contentTypes, md and mdx? I tried to adjust the settings in filePathPattern: 'blog/**/*.mdx','blog/**/*.md', contentType: 'mdx','md',
Any workaround to this problem? I have > 150 md files.
@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);