fix(dev): Updated algolia script for vercel
This commit is contained in:
parent
4f27ac11bb
commit
232e0964b3
2 changed files with 9 additions and 5 deletions
|
@ -8,7 +8,7 @@
|
||||||
"prebuild": "SITE=dev node --experimental-json-modules ../shared/prebuild/index.mjs",
|
"prebuild": "SITE=dev node --experimental-json-modules ../shared/prebuild/index.mjs",
|
||||||
"build": "node --experimental-json-modules ./node_modules/.bin/next build",
|
"build": "node --experimental-json-modules ./node_modules/.bin/next build",
|
||||||
"cibuild": "yarn prebuild && 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",
|
"start": "yarn prebuild && node --experimental-json-modules ./node_modules/.bin/next dev -p 8000",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"serve": "pm2 start npm --name 'dev' -- run start"
|
"serve": "pm2 start npm --name 'dev' -- run start"
|
||||||
|
|
|
@ -26,13 +26,17 @@ import rehypeStringify from 'rehype-stringify'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { getPosts } from '../../freesewing.shared/prebuild/strapi.mjs'
|
import { getPosts } from '../../freesewing.shared/prebuild/strapi.mjs'
|
||||||
import { getMdxFileList } from '../../freesewing.shared/prebuild/mdx.mjs'
|
import { getMdxFileList } from '../../freesewing.shared/prebuild/mdx.mjs'
|
||||||
|
import config from '../algolia.mjs'
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize Algolia client
|
* Initialize Algolia client
|
||||||
*/
|
*/
|
||||||
const client = algoliasearch(process.env.ALGOLIA_APP_ID, process.env.ALGOLIA_API_KEY)
|
const client = algoliasearch(
|
||||||
const index = client.initIndex(process.env.ALGOLIA_INDEX)
|
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
|
* Turn a Strapi blog post into an object ready for indexing
|
||||||
|
@ -142,8 +146,8 @@ const indexMarkdownContent = async () => {
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
if (
|
if (
|
||||||
(process.env.NETLIFY && process.env.CONTEXT === 'production')
|
process.env.VERCEL_ENV === 'production' ||
|
||||||
|| process.env.FORCE_ALGOLIA
|
process.env.FORCE_ALGOLIA
|
||||||
) {
|
) {
|
||||||
await indexMarkdownContent()
|
await indexMarkdownContent()
|
||||||
await indexStrapiContent()
|
await indexStrapiContent()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue