Fix website doc search (#6134)

NEXT_PUBLIC environnement variable values are set at build time and not
run time.
Build is currently performed in Github actions so setting those vars at
runtime has no effect.
We can use a package to automatically pass those variables at runtime
This commit is contained in:
Félix Malfait 2024-07-04 16:46:18 +02:00 committed by GitHub
parent 6cd154aac6
commit aa2218900c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 165 additions and 2 deletions

View File

@ -14,6 +14,7 @@
"database:generate:pg": "npx drizzle-kit generate:pg --config=src/database/drizzle-posgres.config.ts"
},
"dependencies": {
"next-runtime-env": "^3.2.2",
"postgres": "^3.4.3"
}
}

View File

@ -1,5 +1,6 @@
import { DocSearch } from '@docsearch/react';
import { StoredDocSearchHit } from '@docsearch/react/dist/esm/types';
import { env } from 'next-runtime-env';
interface AlgoliaHit extends StoredDocSearchHit {
_snippetResult?: {
@ -47,8 +48,8 @@ export const AlgoliaDocSearch = ({ pathname }: AlgoliaDocSearchProps) => {
</a>
</section>
)}
appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID ?? ''}
apiKey={process.env.NEXT_PUBLIC_ALGOLIA_API_KEY ?? ''}
appId={env('NEXT_PUBLIC_ALGOLIA_APP_ID') ?? ''}
apiKey={env('NEXT_PUBLIC_ALGOLIA_API_KEY') ?? ''}
indexName={`twenty-${indexName}`}
/>
);

View File

@ -1,5 +1,6 @@
import { Metadata } from 'next';
import { Gabarito, Inter } from 'next/font/google';
import { PublicEnvScript } from 'next-runtime-env';
import { AppHeader } from '@/app/_components/ui/layout/header';
@ -40,6 +41,7 @@ export default function RootLayout({
return (
<html lang="en" className={`${gabarito.variable} ${inter.variable}`}>
<body>
<PublicEnvScript />
<EmotionRootStyleRegistry>
<AppHeader />
<div className="container">{children}</div>

159
yarn.lock
View File

@ -8748,6 +8748,13 @@ __metadata:
languageName: node
linkType: hard
"@next/env@npm:14.2.4":
version: 14.2.4
resolution: "@next/env@npm:14.2.4"
checksum: cc284e3dd0666df04d8321645d8409c10cb8e325884c226abbb2e7bea20f0a4232f988216aa506a9d0457b46f28b594a61179d1e978c0ca22497cd8cab8196c7
languageName: node
linkType: hard
"@next/eslint-plugin-next@npm:14.0.4":
version: 14.0.4
resolution: "@next/eslint-plugin-next@npm:14.0.4"
@ -8773,6 +8780,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-darwin-arm64@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-darwin-arm64@npm:14.2.4"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@next/swc-darwin-x64@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-darwin-x64@npm:14.0.4"
@ -8780,6 +8794,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-darwin-x64@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-darwin-x64@npm:14.2.4"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@next/swc-linux-arm64-gnu@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-linux-arm64-gnu@npm:14.0.4"
@ -8787,6 +8808,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-linux-arm64-gnu@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-linux-arm64-gnu@npm:14.2.4"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard
"@next/swc-linux-arm64-musl@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-linux-arm64-musl@npm:14.0.4"
@ -8794,6 +8822,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-linux-arm64-musl@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-linux-arm64-musl@npm:14.2.4"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard
"@next/swc-linux-x64-gnu@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-linux-x64-gnu@npm:14.0.4"
@ -8801,6 +8836,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-linux-x64-gnu@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-linux-x64-gnu@npm:14.2.4"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard
"@next/swc-linux-x64-musl@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-linux-x64-musl@npm:14.0.4"
@ -8808,6 +8850,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-linux-x64-musl@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-linux-x64-musl@npm:14.2.4"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard
"@next/swc-win32-arm64-msvc@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-win32-arm64-msvc@npm:14.0.4"
@ -8815,6 +8864,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-win32-arm64-msvc@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-win32-arm64-msvc@npm:14.2.4"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@next/swc-win32-ia32-msvc@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-win32-ia32-msvc@npm:14.0.4"
@ -8822,6 +8878,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-win32-ia32-msvc@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-win32-ia32-msvc@npm:14.2.4"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@next/swc-win32-x64-msvc@npm:14.0.4":
version: 14.0.4
resolution: "@next/swc-win32-x64-msvc@npm:14.0.4"
@ -8829,6 +8892,13 @@ __metadata:
languageName: node
linkType: hard
"@next/swc-win32-x64-msvc@npm:14.2.4":
version: 14.2.4
resolution: "@next/swc-win32-x64-msvc@npm:14.2.4"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@nivo/calendar@npm:^0.84.0":
version: 0.84.0
resolution: "@nivo/calendar@npm:0.84.0"
@ -15728,6 +15798,16 @@ __metadata:
languageName: node
linkType: hard
"@swc/helpers@npm:0.5.5":
version: 0.5.5
resolution: "@swc/helpers@npm:0.5.5"
dependencies:
"@swc/counter": "npm:^0.1.3"
tslib: "npm:^2.4.0"
checksum: 21a9b9cfe7e00865f9c9f3eb4c1cc5b397143464f7abee76a2c5366e591e06b0155b5aac93fe8269ef8d548df253f6fd931e9ddfc0fd12efd405f90f45506e7d
languageName: node
linkType: hard
"@swc/helpers@npm:~0.5.0":
version: 0.5.3
resolution: "@swc/helpers@npm:0.5.3"
@ -22673,6 +22753,13 @@ __metadata:
languageName: node
linkType: hard
"caniuse-lite@npm:^1.0.30001579":
version: 1.0.30001640
resolution: "caniuse-lite@npm:1.0.30001640"
checksum: d87fce999e52c354029893a23887d2e48ac297e3af55bd14161fcafdd711f97bdb2649c79d2d3049e628603cb59bc4257ca2961644b0b8d206e7b7dd126d37ea
languageName: node
linkType: hard
"capital-case@npm:^1.0.4":
version: 1.0.4
resolution: "capital-case@npm:1.0.4"
@ -38442,6 +38529,19 @@ __metadata:
languageName: node
linkType: hard
"next-runtime-env@npm:^3.2.2":
version: 3.2.2
resolution: "next-runtime-env@npm:3.2.2"
dependencies:
next: "npm:^14"
react: "npm:^18"
peerDependencies:
next: ^14
react: ^18
checksum: 9ac2649fd765b82f340af5d77083f851a4e865acc9e32e9df092ba06cf5f4066b94ee7a3994677ef362d59802457f5becad8d49f3c9a75e77b68179e65c5ecee
languageName: node
linkType: hard
"next-tick@npm:1, next-tick@npm:^1.1.0":
version: 1.1.0
resolution: "next-tick@npm:1.1.0"
@ -38505,6 +38605,64 @@ __metadata:
languageName: node
linkType: hard
"next@npm:^14":
version: 14.2.4
resolution: "next@npm:14.2.4"
dependencies:
"@next/env": "npm:14.2.4"
"@next/swc-darwin-arm64": "npm:14.2.4"
"@next/swc-darwin-x64": "npm:14.2.4"
"@next/swc-linux-arm64-gnu": "npm:14.2.4"
"@next/swc-linux-arm64-musl": "npm:14.2.4"
"@next/swc-linux-x64-gnu": "npm:14.2.4"
"@next/swc-linux-x64-musl": "npm:14.2.4"
"@next/swc-win32-arm64-msvc": "npm:14.2.4"
"@next/swc-win32-ia32-msvc": "npm:14.2.4"
"@next/swc-win32-x64-msvc": "npm:14.2.4"
"@swc/helpers": "npm:0.5.5"
busboy: "npm:1.6.0"
caniuse-lite: "npm:^1.0.30001579"
graceful-fs: "npm:^4.2.11"
postcss: "npm:8.4.31"
styled-jsx: "npm:5.1.1"
peerDependencies:
"@opentelemetry/api": ^1.1.0
"@playwright/test": ^1.41.2
react: ^18.2.0
react-dom: ^18.2.0
sass: ^1.3.0
dependenciesMeta:
"@next/swc-darwin-arm64":
optional: true
"@next/swc-darwin-x64":
optional: true
"@next/swc-linux-arm64-gnu":
optional: true
"@next/swc-linux-arm64-musl":
optional: true
"@next/swc-linux-x64-gnu":
optional: true
"@next/swc-linux-x64-musl":
optional: true
"@next/swc-win32-arm64-msvc":
optional: true
"@next/swc-win32-ia32-msvc":
optional: true
"@next/swc-win32-x64-msvc":
optional: true
peerDependenciesMeta:
"@opentelemetry/api":
optional: true
"@playwright/test":
optional: true
sass:
optional: true
bin:
next: dist/bin/next
checksum: 630c2a197b57c1f29caf4672a0f8fb74dbb048e77e4513f567279467332212f3eebcb68279885f1d525d7aaebbb452f522b02c0b5cd3ca66f385341e4b4eac67
languageName: node
linkType: hard
"nice-napi@npm:^1.0.2":
version: 1.0.2
resolution: "nice-napi@npm:1.0.2"
@ -47715,6 +47873,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "twenty-website@workspace:packages/twenty-website"
dependencies:
next-runtime-env: "npm:^3.2.2"
postgres: "npm:^3.4.3"
languageName: unknown
linkType: soft