Umami Demo
How to run the Umami demo on your local.
Drupal
- Create a new Drupal project
composer create-project drupal/recommended-project umami
- Edit
composer.json
file and add the following patches underextra
.
"extra": { "patches": { "drupal/subrequests": { "Get same results on different request": "https://www.drupal.org/files/issues/2019-07-18/change_request_type-63049395-09.patch" }, "drupal/decoupled_router": { "Unable to resolve path on node in other language than default": "https://www.drupal.org/files/issues/2021-05-05/3111456-34.patch" } },}
- Add dependencies
composer require drupal/next drupal/jsonapi_menu_items drupal/jsonapi_views 'drupal/jsonapi_resources:^1.0@beta'
Install Drupal. Make sure you select Demo: Umami Food Magazine (Experimental) as the installation profile.
For a quick installation, you may also use the
quick-start
command:
php -d memory_limit=256M ./web/core/scripts/drupal quick-start demo_umami
- Enable the following modules:
- Next
- Next JSON:API
- JSON:API Menu Items
- JSON:API Views
Next.js
- Grab a copy of the Next.js code:
git clone https://github.com/chapter-three/next-example-umami
- Install dependencies
yarn install
- Copy
.env.example
to.env.local
and update the values to point to your Drupal site:
NEXT_PUBLIC_DRUPAL_BASE_URL=http://drupal.testNEXT_IMAGE_DOMAIN=drupal.test
- Start the development server
yarn dev
- Visit
http://localhost:3000
to see the Next.js site.
How to enable authentication
We use the simple_oauth module for authentication.
- Visit
/admin/config/people/simple_oauth
. - Click on Generate Keys.
- Enter
sites/default/files
for Directory for the keys and click Generate. - Visit
/admin/config/services/consumer
and edit the default client. - Enter
weDKc7PD845kq49JfPeYmsZ48e
under New Secret and Save. - Update your
.env.local
with the following:
# RequiredNEXT_PUBLIC_DRUPAL_BASE_URL=http://localhost:8888NEXT_IMAGE_DOMAIN=localhost
+ # Authentication (Bearer)+ NEXTAUTH_SECRET=zdauNuBL7lLAHT9zIpxExCThVHSSOfIwouGOhr5cjWQ+ NEXTAUTH_URL=http://localhost:3000+ DRUPAL_CLIENT_ID=YOUR_DEFAULT_CLIENT_UUID_HERE+ DRUPAL_CLIENT_SECRET=weDKc7PD845kq49JfPeYmsZ48e
- Restart the Next.js development server.
- If you visit
http://localhost:3000/login
, you should now be able to login with the Drupal admin username and password.
How to enable JSON:API Write Operations
- Visit
/admin/config/services/jsonapi
- Under Allowed Operations, select Accept all JSON:API create, read, update, and delete operations..
- Save configuration
You can now visit http://localhost:3000/articles/new
to create a new article.