diff --git a/example/.env.template b/example/.env.template new file mode 100644 index 0000000..a34e3b7 --- /dev/null +++ b/example/.env.template @@ -0,0 +1,2 @@ +REACT_APP_ALGOLIA_APP_ID= +REACT_APP_SEARCH_KEY= diff --git a/example/README.md b/example/README.md index 1071092..81ab7a7 100644 --- a/example/README.md +++ b/example/README.md @@ -3,7 +3,18 @@ It is linked to the firecms package in the parent directory for development purposes. -In a regular project you would link the dependencies regularly using `npm` +In a regular project you would link the dependencies regularly using the `npm` +repository. + +To run this project locally you can set your Firebase configuration in the file +`firebase_config.ts` under `src` You can run `yarn install` and then `yarn start` to test this package. +### Algolia search + +The example backend included in this package indexes various collections to +Algolia, using Cloud functions. If you deploy it your data will be indexed. +Then you can add your appId and searchKey to the .env file in the root of this +example project. + diff --git a/example/package.json b/example/package.json index cbc3196..93f676e 100644 --- a/example/package.json +++ b/example/package.json @@ -7,10 +7,10 @@ "@material-ui/icons": "link:../node_modules/@material-ui/icons", "@material-ui/pickers": "link:../node_modules/firebase", "firebase": "link:../node_modules/firebase", + "firecms": "link:..", "react": "link:../node_modules/react", "react-dom": "link:../node_modules/react-dom", - "react-scripts": "link:../node_modules/react-scripts", - "firecms": "link:.." + "react-scripts": "link:../node_modules/react-scripts" }, "scripts": { "start": "node ../node_modules/react-scripts/bin/react-scripts.js start", diff --git a/example/src/index.tsx b/example/src/index.tsx index 32d067a..961f7d6 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -1,7 +1,7 @@ import React from "react"; import ReactDOM from "react-dom"; import "./index.css"; -import logo from './images/test_shop_logo.png'; +import logo from "./images/test_shop_logo.png"; import * as serviceWorker from "./serviceWorker"; @@ -271,7 +271,16 @@ const usersSchema: EntitySchema = { } }; -const usersSearchDelegate = new AlgoliaTextSearchDelegate("Y6FR1MDSVW", "f084e6dcc154c04295c8124dbb797ff1", "users"); +let usersSearchDelegate: AlgoliaTextSearchDelegate | undefined = undefined; +if (process.env.REACT_APP_ALGOLIA_APP_ID && process.env.REACT_APP_ALGOLIA_SEARCH_KEY) { + usersSearchDelegate = new AlgoliaTextSearchDelegate( + process.env.REACT_APP_ALGOLIA_APP_ID, + process.env.REACT_APP_ALGOLIA_SEARCH_KEY, + "users"); +} else { + console.error("ALGOLIA_APP_ID or SEARCH_KEY env variables not specified"); + console.error("Text search not enabled"); +} ReactDOM.render( ; diff --git a/yarn.lock b/yarn.lock index 57e8100..a8d379b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12596,6 +12596,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typeface-roboto@^0.0.75: + version "0.0.75" + resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-0.0.75.tgz#98d5ba35ec234bbc7172374c8297277099cc712b" + integrity sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg== + typescript@^3.8.3: version "3.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"