Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: use env vars instead of hardcoded credentials #527

Merged
merged 5 commits into from
May 16, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_ALGOLIA_API_KEY=
NEXT_PUBLIC_ALGOLIA_APP_ID=
7 changes: 5 additions & 2 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ type Props = {
metaTitle?: string;
whiteBg?: boolean;
};
// apiKey and appId are set in the .env.local file
const algoliaAppId: string = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID as string;
const algoliaApiKey: string = process.env.NEXT_PUBLIC_ALGOLIA_API_KEY as string;

// const responsiveClasses = 'w-screen'

@@ -102,8 +105,8 @@ export default function Layout({
export const Search = () => {
return (
<DocSearch
appId='6ZT4KX2OUI'
apiKey='69f76fba13585144f6686622e9c8f2a8'
appId={algoliaAppId}
apiKey={algoliaApiKey}
indexName='json-schema'
/>
);
52 changes: 28 additions & 24 deletions pages/index.page.tsx
Original file line number Diff line number Diff line change
@@ -16,6 +16,11 @@ import axios from 'axios';
import ical from 'node-ical';
import moment from 'moment-timezone';
import { useTheme } from 'next-themes';

// apiKey and appId are set in the .env.local file
const algoliaAppId: string = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID as string;
const algoliaApiKey: string = process.env.NEXT_PUBLIC_ALGOLIA_API_KEY as string;

/* eslint-enable */
export const getStaticProps: GetStaticProps = async () => {
const files = fs.readdirSync(PATH);
@@ -208,30 +213,29 @@ const Home = (props: any) => {
JSON Schema enables the confident and reliable use of the JSON
data format.
</h2>

<div className='lg:w-[650px] mx-auto my-10 grid grid-cols-1 lg:grid-cols-3 gap-8 justify-items-center '>
<Link
href='/learn/getting-started-step-by-step'
className=' flex items-center justify-center rounded border-2 border-white dark:border-none text-white w-[194px] h-[40px] font-semibold bg-primary dark:shadow-2xl'
>
Getting started
</Link>
<Link
href='/slack'
className=' flex items-center justify-center rounded border-2 border-white dark:border-none text-white w-[194px] h-[40px] font-semibold bg-primary dark:border-shadow-white dark:shadow-2xl'
>
Join Slack
</Link>

<div className='flex herobtn items-center justify-center font-semibold w-[194px] h-[40px] rounded border-2 border-white dark:border-none text-white bg-primary mx-auto dark:shadow-2xl'>
<div className='flex flex-row justify-center items-center mr-4 '>
<DocSearch
appId='6ZT4KX2OUI'
apiKey='69f76fba13585144f6686622e9c8f2a8'
indexName='json-schema'
/>
<p>Search</p>
</div>
</div>
<div className='lg:w-[650px] mx-auto my-10 grid grid-cols-1 lg:grid-cols-3 gap-8 justify-items-center '>
<Link
href='/learn/getting-started-step-by-step'
className=' flex items-center justify-center rounded border-2 border-white dark:border-none text-white w-[194px] h-[40px] font-semibold bg-primary dark:shadow-2xl'
>
Getting started
</Link>
<Link
href='/slack'
className=' flex items-center justify-center rounded border-2 border-white dark:border-none text-white w-[194px] h-[40px] font-semibold bg-primary dark:border-shadow-white dark:shadow-2xl'
>
Join Slack
</Link>

<div className='flex herobtn items-center justify-center font-semibold w-[194px] h-[40px] rounded border-2 border-white dark:border-none text-white bg-primary mx-auto dark:shadow-2xl'>
<div className='flex flex-row justify-center items-center mr-4 '>
<DocSearch
appId={algoliaAppId}
apiKey={algoliaApiKey}
indexName='json-schema'
/>
<p>Search</p>
</div>
</div>