git clone git@github.com:aimementoring/website.git
cd website
yarn
yarn dev
yarn build && yarn start
render
method something like this:
render() {
return (
<Layout>
{/* YOUR COMPONENT HTML */}
</Layout>
);
}
server.js
and you can specify the URL you want to use there, the code is something like this:
server.get('/your-component-url', (req, res) => {
const pagePath = '/yourComponentFolder';
const queryParams = {};
return ssrCache({
req, res, pagePath, queryParams,
});
});
Use dynamic imports instead of importing directly every time you think it is possible to import the component dynamically. To do that, first you need to use a dynamic utils from next import dynamic from 'next/dynamic';
. After that, you can import a component dynamically using:
Good way to import components
const MyComponent = dynamic(() => import('../components/myComponent'));
Bad way to import components
import MyComponent from '../components/myComponent';
This is important because we can reduce the amount of lines and code for the first render, and we load the components asynchronously.
We use dynamic imports for React Components which has render method, and for UI libraries (e.g. Aime Blueprint component). It is important to use only in those cases, and we should avoid using it when we load data, functional libraries or methods, because it could break prerender, and also we want the data directly when we render the page for the SEO.
It is quite important to create small components and small pages, so we can have good performance on the website.
Instead of adding a long HTML in your render method on your page, you should break it down, and create small components from there that you can import in your page dynamically.
The main idea with that is:
If you want to test aws s3 command locally, you need first to install aws command, following next instructions:
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
or you can install it with python, based on aws documentation
# Install pip3 if you don't have it yet
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
# Install aws cli
pip3 install awscli --upgrade --user
After installation is finished, verify the installation has completed correctly with the following command:
pip3 install awscli --upgrade --user
Now follow next steps:
cp -R .aws ~/.awd
to save credentials in our computeraws configure list
to see what credentials you have defined in your computer. Expected output should look like this:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************CNUG shared-credentials-file
secret_key ****************v962 shared-credentials-file
region ap-southeast-2 config-file ~/.aws/config
sync:aws:next:staging
or any other command on aws to check if it worksThere are two folders on AWS where we store all our assets - images, fonts, files, etc. These are aimementoring-staging
(d2cl4o0mkg71rr
) and aimementoring
(d1muvgoqe3g8vw
).
To manage the content of reports, terms & conditions and stories we use Contentful. You can find the login for content editors in 1Password; contact your team leads to get access as a developer.
We use two different environments, staging
and master
.
(Check your .env
to make sure you're using staging
for development.)
Contentful has a content model. You can change it in the UI, but if you want to make bigger changes and migrate existing content, you might want to use migrations.
Migrations are written in Javascript. You can find some examples in the /migrations
folder.
You find more info here: https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/
$ yarn global add contentful-cli
$ contentful login
, log into Contentful in your browser and paste the token.contentful space migration --space-id SPACE_ID --environment-id 'staging' migrations/myMigration.js