PageDepot: Parameters
Parameters
Section titled “Parameters”What parameter values you can have in your page URL is configured using the parameters. But, because PageDepot uses Astro, and Astro is mainly a static site builder, all possible parameter values must be known at build time. Therefore, Astro needs to be told every combination of parameters that should be possible. Fortunately, you don’t actually need to write every combination down, you can just specify the possible parameter values. PageDepot generates the combinations for Astro when building your site.
Instead, you can add a post parameter and make it refer to the posts module, and say that the parameter value comes
from the slug field.
You can also add a lang parameter for example, where you define the value en, and then add a new entry for lang,
where you define de.
Assuming you have posts with slugs lorem-ipsum, dolor and oppenheimer, the resulting paths would be:
/posts/en/lorem-ipsum/posts/de/lorem-ipsum/posts/en/dolor/posts/de/dolor/posts/en/oppenheimer/posts/de/oppenheimer
However, even moderate amounts of parameters can add up to huge amounts of combinations, so much that even when PageDepot generates them for you, the runtime and memory requirements become too high to handle. In that case, you need server-side rendering (SSR) for your page. This has the benefit of evaluating each parameter when the page is accessed, instead of generating them all in advance. Currently, the SSR feature is under construction.
Sections
Section titled “Sections”A section is the most basic building block, and is basically nothing more than a component in Astro or Vue.
In fact, a section in PageDepot is directly converted to a component file during the provisioning step, be it
an .astro file or .vue single-file-component.
Sections have a name, a type, props and code.
The type can be one of astro or vue.
It decides what type of code you can write.
The props define the input parameters your section can receive.
This is used for Brezel to be able to define a fitting UX to edit these props.
It is also used by PageDepot to prepare the prop values accordingly.
For example, if the prop’s type is select, PageDepot loads the respective entity from Brezel.
The syntax is
{ "propName": { "type": "propType" }}or its shorthand
{ "propName": "propType"}For types like object or list, you can nest prop definitions:
{ "myObject": { "type": "object", "props": { "someProp": "text" } }, "myList": { "type": "list", "listType": { "type": "object", "props": { "someProp": "text" } } }}Then, when using the section in a page slot, you would give the params like this:
[ { "slot": "default", "sections": [ { "section": { "id": 10 }, "myObject": { "someProp": "lorem ipsum" }, "myList": [ { "someProp": "dolor sit amet" } ] } ] }]Available types
Section titled “Available types”Text (text)
Section titled “Text (text)”{ "type": "text"}Number (number)
Section titled “Number (number)”{ "type": "number"}Object (object)
Section titled “Object (object)”{ "type": "object", "props": {}}List (list)
Section titled “List (list)”{ "type": "list", "listType": {}}Entity (select)
Section titled “Entity (select)”Usage in props
Section titled “Usage in props”{ "type": "select", "options": { "references": "the_module" }}Type schema for params
Section titled “Type schema for params”An entity object with id.
type EntityParams = { id: string | number};Entities (entities)
Section titled “Entities (entities)”Usage in props
Section titled “Usage in props”An object with optional property module (the module identifier).
{ "type": "entities", "module": "the_module"}Example for section code
Section titled “Example for section code”const entities = props.entities;Type schema for params
Section titled “Type schema for params”type EntitiesParams = { module?: string; filters?: Array<Record<string, unknown>> | Array<Array<Record<string, unknown>>>; results?: number;}Module (module)
Section titled “Module (module)”Example for section code
Section titled “Example for section code”const module = props.module;module.fields.forEach(field => { console.log(field);})Type schema for params
Section titled “Type schema for params”type ModuleParams = { identifier: string;};Image (image)
Section titled “Image (image)”Example for section code
Section titled “Example for section code”const {src, alt} = props.image;Type schema for params
Section titled “Type schema for params”type ImageParams = { id: string | number; module?: string;}The code is the actual code that defines your section. Here, you write the markup and any logic you need for the rendering. You also need to define the props again. For example:
<template> <article> <h3>{{ post.title }}</h3> <WYSIWYG :content="post.content"/> <ShareButtons :post="post"/> </article></template>
<script setup>import {defineProps} from 'vue';import WYSIWYG from '~/components/WYSIWYG.vue';import ShareButtons from '~/components/sections/ShareButtons.vue';const props = defineProps({ post: Object, astro: Object,});</script>Here, there is also the astro property, which gives access to
the global Astro object.
You can also import other sections you have defined, like ShareButtons in this case.