1
0
Fork 0

fix(dev): Updated algolia script for vercel

This commit is contained in:
Joost De Cock 2022-08-10 11:50:21 +02:00
parent 4f27ac11bb
commit 232e0964b3
2 changed files with 9 additions and 5 deletions

View file

@ -8,7 +8,7 @@
"prebuild": "SITE=dev node --experimental-json-modules ../shared/prebuild/index.mjs",
"build": "node --experimental-json-modules ./node_modules/.bin/next build",
"cibuild": "yarn prebuild && node --experimental-json-modules ./node_modules/.bin/next build",
"export": "yarn prebuild && next build && next export && node scripts/algolia.mjs",
"start": "yarn prebuild && node --experimental-json-modules ./node_modules/.bin/next dev -p 8000",
"lint": "next lint",
"serve": "pm2 start npm --name 'dev' -- run start"

View file

@ -26,13 +26,17 @@ import rehypeStringify from 'rehype-stringify'
import yaml from 'yaml'
import { getPosts } from '../../freesewing.shared/prebuild/strapi.mjs'
import { getMdxFileList } from '../../freesewing.shared/prebuild/mdx.mjs'
import config from '../algolia.mjs'
dotenv.config()
/*
* Initialize Algolia client
*/
const client = algoliasearch(process.env.ALGOLIA_APP_ID, process.env.ALGOLIA_API_KEY)
const index = client.initIndex(process.env.ALGOLIA_INDEX)
const client = algoliasearch(
config.algolia.app,
process.env.ALGOLIA_API_WRITE_KEY
)
const index = client.initIndex(config.algolia.index)
/*
* Turn a Strapi blog post into an object ready for indexing
@ -142,8 +146,8 @@ const indexMarkdownContent = async () => {
const run = async () => {
if (
(process.env.NETLIFY && process.env.CONTEXT === 'production')
|| process.env.FORCE_ALGOLIA
process.env.VERCEL_ENV === 'production' ||
process.env.FORCE_ALGOLIA
) {
await indexMarkdownContent()
await indexStrapiContent()