Skip to content

Commit

Permalink
customize: add dynamic registration of static pages through config
Browse files Browse the repository at this point in the history
* Update the documentation to incorporate the changes introduced in: inveniosoftware/invenio-app-rdm#2651

* Added missing syntax highlighting to Markdown code blocks in static_pages page.
  • Loading branch information
Samk13 authored and slint committed May 16, 2024
1 parent 40dab1f commit a7a3bac
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions docs/customize/static_pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ And you can change them using the administration panel in v12.

To add the new static pages, create a file named `pages.yaml` in the `app_data` folder:

```
```bash
app_data/
└── pages.yaml
```
Expand All @@ -26,14 +26,29 @@ Then, inside the file, define the URL, the title, the description and the HTML t
InvenioRDM will look for the content of each static page in the `template` HTML file, located in a new sub-folder named `pages`:

```
```bash
app_data/
└── pages
└──my_custom_page.html
```

The template file content is what will be imported in the database and rendered to the user when navigating to the page's URL.

_Introduced in InvenioRDM v12_

## Register Pages

InvenioRDM now allows for dynamic registration of static pages through configuration. after doing the steps above, Add the `APP_RDM_PAGES` variable to your `invenio.cfg` to map the page identifiers to URLs, this enables the application to serve these pages dynamically, For example:

```py
APP_RDM_PAGES = {
"my-custom-page": "/my-custom-page",
"about": "/about",
}
```

Each key represents a page identifier while the value specifies the URL path under which the page will be accessible.

## Load pages

To load the new static page to your instance, you have 2 options:
Expand All @@ -58,7 +73,7 @@ This will wipe out all previously created static pages and load them again. I.e.

Your custom template will be an extension of the base template [defined in `invenio-app-rdm`](https://github.com/inveniosoftware/invenio-app-rdm/blob/9f1ba6a646362ff80de6b0c9cd092209e9190c44/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/default_static_page.html). If you want to create your own base template, you can do it by setting the following variables in your `invenio.cfg` file:

```
```py
PAGES_DEFAULT_TEMPLATE = "my_site/my_custom_base_template.html"
PAGES_TEMPLATES = [
Expand All @@ -69,7 +84,7 @@ PAGES_TEMPLATES = [

This implies that your new template was created in

```
```bash
templates
└── my_site/my_custom_base_template.html
```
Expand Down

0 comments on commit a7a3bac

Please sign in to comment.