Skip to main content

NextJS Static Site Generated Powr tutorials installation

[last update: June 27 2022 by [email protected]]

POC superlongseo layout for Nextjs using TailwindCSS Deployed on vercel https://nextjs-powr-tutorials.vercel.app/

Preparing the project​

Make sure that you have node version >= 14

Create env.local from env.example and define following variables:

STRAPI_URL=https://cms.powr-staging.io/

Running locally in development mode​

    node download_all.js # => downloads all the simple copies as JSON files
npm run dev

Building and deploying for production/staging​

  • Merging to main will deploy the app on Vercel production environment.
  • Merging to staging will deploy the app on Vercel staging environment.

Tutorials Static Pages​

pages/tutorial/[platformId]/[appId].js

platformId - platform id from Strapi Platforms collection

appId - platform id from Strapi App Details collection

In order to generate set of tutorials for every platform and app SupahLongSeo should be in [appId].js.

The purpose of /general-copy/tutorials endpoint​

  1. It's a lot faster this way.
  2. General copies and simple copies contain seperate versions for each locale. We cannot just retrieve all versions by using /general-copies?_locale=all&_limit=-1 due to heap overflow in Node.js and other issues (taking into account heap limit of size 8196).
  3. We can eliminate heap overflow mentioned in point #2 by retrieving each version in separate API call. However, it is super slow and brings a ton of overhead (number_of_locales * (time_to_process_one_api_call + time_to_process_one_sql_query_with_WHERE + json_serialization_of_that_sql_query)).
  4. That is why it's better to preload and serve them in one endpoint.

Automatic tests

tech description​

The main goal was to make an e2e test before the push, which takes no more than 10 minutes and checks a few randomly selected pages described in the ENV page count

  • To set up the tests, add TEST_ENV=true and PAGES_AMOUNT=500 to .env. The optimum number of testing 500 for 5-8 min.
  • It will stop executing if any error occurs and the push request fails
  • [appId].js generates a json file with the data of all collected applications to test them

if tests fails​

  • Make sure that your javascript heap size more than 2048, you should one of this before build
    export NODE_OPTIONS="--max-old-space-size=5120" # Increases to 5 GB
    export NODE_OPTIONS="--max-old-space-size=6144" # Increases to 6 GB
    export NODE_OPTIONS="--max-old-space-size=7168" # Increases to 7 GB
    export NODE_OPTIONS="--max-old-space-size=8192" # Increases to 8 GB
  • by logs find tutorial page with given plugin and app and debug
  • If you must push without test: you can disable them by removing TEST_ENV=true