@@ -15,6 +15,13 @@ import rehypeKatex from "rehype-katex";
1515import rehypeAutoLinkHeadings from "rehype-autolink-headings" ;
1616import rehypeRewrite from "rehype-rewrite" ;
1717import { h } from "hastscript" ;
18+ import { MeiliSearch } from "meilisearch" ;
19+
20+ const client = new MeiliSearch ( {
21+ host : process . env . MEILISEARCH_HOST ,
22+ apiKey : process . env . MEILISEARCH_API_KEY ,
23+ } ) ;
24+
1825
1926firebaseAdmin . initializeApp ( {
2027 credential : firebaseAdmin . credential . cert ( {
@@ -68,10 +75,7 @@ async function main() {
6875 ) . exists ;
6976
7077 const projectReactionsExists = (
71- await firestore
72- . collection ( "projectReactions" )
73- . doc ( fileNameWithoutExtension )
74- . get ( )
78+ await firestore . collection ( "projectReactions" ) . doc ( fileNameWithoutExtension ) . get ( )
7579 ) . exists ;
7680
7781 if ( ! projectReactionsExists ) {
@@ -81,12 +85,7 @@ async function main() {
8185 }
8286
8387 const projectContent = fs . readFileSync (
84- path . resolve (
85- process . cwd ( ) ,
86- "projects" ,
87- projectFolderName ,
88- projectMdxFile
89- ) ,
88+ path . resolve ( process . cwd ( ) , "projects" , projectFolderName , projectMdxFile ) ,
9089 "utf-8"
9190 ) ;
9291
@@ -149,6 +148,21 @@ async function main() {
149148 } ,
150149 } ) ;
151150
151+ try {
152+ await client . index ( "projects" ) . addDocuments ( [
153+ {
154+ id : fileNameWithoutExtension ,
155+ title : projectMatter . data . title ,
156+ description : projectMatter . data . description ,
157+ content : projectMatter . content ,
158+ author : projectMatter . data . author ,
159+ tags : projectMatter . data . tags || [ ] ,
160+ } ,
161+ ] ) ;
162+ } catch ( error ) {
163+ console . error ( "Error adding document to MeiliSearch:" , error ) ;
164+ }
165+
152166 if ( ! projectExists ) {
153167 await firestore
154168 . collection ( "projects" )
0 commit comments