DEV Community

Discussion on: Comparison of MDX integration strategies with Next.js

Collapse
 
sanketss84 profile image
Sanket Sonvane

Thanks for this, I also ended up choosing @next/mdx as I like minimal overhead and all my needs are being met. With Next 12 this seems to be a hassle free option for now.

Collapse
 
tylerlwsmith profile image
Tyler Smith

Thanks for reading. I'm glad you got some value out of it!

Collapse
 
sanketss84 profile image
Sanket Sonvane • Edited

What strategy do you use for listing blog posts and site wide search ?

Option 1
I am thinking of going with creating a json file called posts.json where I will add paths manually for all MDX posts rather than doing file path scanning jugglery. This json object will have slug, path, tags, create date, author. I shall also use this along with fuze.js to filter the results.

Option 2
There is a library called glob which scans path for *.MDX files as well

For search I am thinking of using fuze.js
I have heard (not tried at all) about algolia instant search and elastic search but i am wondering do I really need external indexes ?

What are your thoughts ?

Thread Thread
 
tylerlwsmith profile image
Tyler Smith

I was using markdown for a few pages, so I haven't implemented this in Next.js. I'd personally lean towards option 2 and be very careful to make sure that no one can execute a directory traversal attack.

In the past on non-Next.js sites, I've actually ingested the markdown content into a SQLite DB on application bootup and used that for searching with LIKE queries. It wasn't typo tolerant, but it was good enough for my needs. I had less than 100 posts though, and if I had upwards of 1000 it would probably slow down the application bootup.

Thread Thread
 
sanketss84 profile image
Sanket Sonvane

Thanks for sharing your thoughts.