Skip to content

Commit

Permalink
Update documentation ( new env var names with ENONIC_ etc.) enonic#691
Browse files Browse the repository at this point in the history
  • Loading branch information
pmi committed Sep 12, 2023
1 parent f9d6dbf commit c1b0389
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 48 deletions.
30 changes: 17 additions & 13 deletions docs/deployment.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ You are now ready to deploy the the front-end application.
. Create a new project `enonic-tutorial` and connect it to the repo you created in the previous step.
. **Add the following environment variables** to the project (name:value):
+
* CONTENT_API_DRAFT:<enonic route URL>/draft
* CONTENT_API_MASTER:<enonic route URL>/master
* API_TOKEN:<yourSecret>
* ENONIC_API:<enonic route URL>
* ENONIC_API_TOKEN:<yourSecret>

. **Verify the result**. The front-page of your app should now display a 404 - as you are back to the originally imported content without a site.
+
Expand All @@ -89,28 +88,33 @@ With the front-end running, you can finally link it to Content Studio, and start
NOTE: You now have to create your site and tree structure once more, or for convenience, you may export content from your local machine, and importing it to the server using the https://market.enonic.com/vendors/glenn-ricaud/data-toolbox[Data Toolbox app].

. **Install the Next.XP app** `Solution` -> `Applications` -> `Install` -> Search for `Next.XP`, select it an click install
. **Add configuration**. This time, rather than configuring the app within the site, do this via config files.
+
TIP: This is safer and more flexible than storing the configuration within the content.
. **Add configuration**.
This way you can override defaults and add more configurations.
+
image:console-configure-app.png[title="Configure the Next.XP application in the solution console",width=769px]
+
.Add the following to the app config field:
By default `Next.XP` uses the following values:
+
`url: *http://127.0.0.1:3000*`
+
`secret: *mySecret*`
+
.Add the following lines to the app config field if you want to override default values:
[source,properties]
----
nextjs.url = <Vercel app URL>
nextjs.secret = <yourSecret>
nextjs.default.url = <Vercel app URL>
nextjs.default.secret = <yourSecret>
----
+
.To support multiple sites and front-ends, use this format instead:
.You can also add as many named configurations as needed:
[source,properties]
----
nextjs.<projectID>.<siteName>.url = <Vercel app URL>
nextjs.<projectID>.<siteName>.secret = <yourSecret>
nextjs.<configurationName>.url = <Vercel app URL>
nextjs.<configurationName>.secret = <yourSecret>
----
+
NOTE: If you imported content from your local environment, the following two steps can be skipped
. **Add the Next.XP app to the site**. Since you have already placed configuration on file, simply adding the app to the site will do the trick.
. **Add the Next.XP app to the site**.Since you have already placed configuration on file, simply adding the app to the site will do the trick.
. **Save and verify** that the configuration is working by testing the Content Studio preview.

== Task: Publish a page
Expand Down
Binary file modified docs/media/content-studio-configure-nextxp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions docs/nextjs-setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ The following configuration values should match your environment
[source,files]
----
# Provide a unique value which will be used to secure the preview mode
API_TOKEN=mySecretKey
ENONIC_API_TOKEN=mySecretKey
# Enonic app name, must match the name of your app
APP_NAME=com.example.myproject
ENONIC_APP_NAME=com.example.myproject
# Path to site, or site ID
SITE_KEY=/hmdb
# Enonic XP projects configuration for different locales
ENONIC_PROJECTS=hmdb/hmdb
# Absolute URL to Content API
CONTENT_API_DRAFT=http://127.0.0.1:8080/site/moviedb/draft
CONTENT_API_MASTER=http://127.0.0.1:8080/site/moviedb/master
ENONIC_API=http://127.0.0.1:8080/site
----

TIP: The configuration values can be overridden later when deplying your app to a live server.
Expand Down
33 changes: 30 additions & 3 deletions docs/preview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,37 @@ Add the Next.XP app to the site by selecting it in the applications combobox.
+
image:content-studio-add-nextxp.png[title="Open app config by pressing pencil icon",width=597px]
+
Configure the `Next.XP` app by clicking the pencil icon. Use the same values that were configured in the Next.js front-end:
Save the site to make all the features of the app available.

* `http://localhost:3000[http://localhost:3000^]`
* `mySecretKey`.
. *Configure the `Next.XP` app*
+
By default `Next.XP` uses the following values:
+
`url: *http://127.0.0.1:3000*`
+
`secret: *mySecret*`
+
You can change default values and add more configurations by adding a config file named `_com.enonic.app.nextxp.cfg_` in `_<xp-home>/config/_` folder:
+
[source,properties]
----
# uncomment to override default values
# nextjs.default.secret=yourSecret
# nextjs.default.url=http://127.0.0.1:4242
#
# config 'someName'
nextjs.someName.secret=yourSecret
nextjs.someName.url=https://your.next-site.com
#
# config 'anotherName'
nextjs.anotherName.secret=yourOtherSecret
nextjs.anotherName.url=https://your.other-next-site.com
# ...
----
+
NOTE: Remember to update properties' values with your own data
+
To assign a configuration to a site, click the pencil icon next to the `Next.XP` app name in the site wizard and select from the list of named configurations:
+
image:content-studio-configure-nextxp.png[title="Form with fields for server url and nextjs token",width=771px]

Expand Down
51 changes: 28 additions & 23 deletions docs/release/upgrade.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,50 @@ IMPORTANT: Guillotine version 7 is required if you need to modify graphql schema

== Upgrading from v1.x

1. Update env vars to:
. Update env vars to:

APP_NAME -> ENONIC_APP_NAME
CONTENT_API -> ENONIC_API
remove CONTENT_API_MASTER
remove CONTENT_API_DRAFT
add ENONIC_API
API_TOKEN -> ENONIC_API_TOKEN
remove SITE_KEY
add ENONIC_PROJECTS=<repo-name>/site/path[,<lang>:<repo-name>/site/path,...]

2. Add i18n config block to next.config.js
. Add i18n config block to next.config.js

i18n: {
locales: ['en', 'no'],
defaultLocale: 'en',
}

3. Remove `lib-nextxp` dependency from your Enonic XP app build.gradle file
4. Install `Next.XP` application from Enonic Market
5. Add config file `_com.enonic.app.nextxp.cfg_` with the following content:

# default configuration
# nextjs.default.secret=yourSecret
# nextjs.default.url=http://127.0.0.1:4242
#
# config 'someName'
nextjs.someName.secret=yourSecret
nextjs.someName.url=https://your.next-site.com
#
# config 'anotherName'
nextjs.anotherName.secret=yourOtherSecret
nextjs.anotherName.url=https://your.other-next-site.com
# ...
. Remove `lib-nextxp` dependency from your Enonic XP app build.gradle file
. Install `Next.XP` application from Enonic Market
. Create config file named `_com.enonic.app.nextxp.cfg_` in `_<xp-home>/config/_` folder to change default values and add more configurations:
+
[source,properties]
----
# uncomment to override default values
# nextjs.default.secret=yourSecret
# nextjs.default.url=http://127.0.0.1:4242
#
# config 'someName'
nextjs.someName.secret=yourSecret
nextjs.someName.url=https://your.next-site.com
#
# config 'anotherName'
nextjs.anotherName.secret=yourOtherSecret
nextjs.anotherName.url=https://your.other-next-site.com
# ...
----
+
NOTE: Remember to update properties' values with your own data

6. remove `lib-guillotine` dependency from your enonic app build.gradle file
7. install `Guillotine` application from Enonic Market
. remove `lib-guillotine` dependency from your enonic app build.gradle file
. install `Guillotine` application from Enonic Market
+
NOTE: Use Guillotine 7 or higher if you need to extend the graphql schema

8. Add `Next.XP` application to your site in every layer and save it
9. Default configuration will be used automatically for each site.
. Add `Next.XP` application to your site in every layer and save it
. Default configuration will be used automatically for each site.
You can change it by going to `Next.XP` application config in each site and selecting named configurations.
5 changes: 2 additions & 3 deletions docs/tldr.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ Vercel are the makers of Next.js, and you'll be using their service to host the
. Create a new project i.e. `enonic-demo`, and follow the steps to connect it to the Git repo you created in step 2.
. **Add environment variables** telling the app where to find the API endpoints, as well as a secret you will need to access preview mode in a later step.
+
KEY:VALUE:: CONTENT_API_DRAFT:<API URL>/draft
KEY:VALUE:: CONTENT_API_MASTER:<API URL>/master
KEY:VALUE:: API_TOKEN:mySecretKey
KEY:VALUE:: ENONIC_API:<API URL>
KEY:VALUE:: ENONIC_API_TOKEN:mySecretKey
+
. After deploying, the Vercel app should render the front page:
+
Expand Down

0 comments on commit c1b0389

Please sign in to comment.