Hi,
pretty new to Kirby and already with a fairly complex setup as it seems. I am using Kirby headless with the KQL Plugin. Astro JS in the frontend.
My content is based on custom blocks. One of the blocks is a list of links. Links can be internal (pages), files or external (url).
I am using a structure field with an object field inside to have the options for link label and target. Blueprint looks like this:
name: Links
icon: dots
fields:
links:
label: Links
type: structure
sortable: true
fields:
linkdata:
label: Link
type: object
fields:
link:
type: link
options:
- page
- url
- file
label:
label: Beschriftung
type: text
target:
label: Ziel
type: toggle
text: In neuem Fenster öffen?
My current problem is the conversion of a page type link to a relative url / path. My fetch request body / query looks like this. “blocks” beeing a blocks-type field called “content” (might need to finalise naming here later )
"blocks": {
"query": "page.content.content.toBlocks",
"select": {
"type": true,
"content": true,
"image": {
"query": "block.image.toFile",
"select": {
"file": "file",
"srcset": "file.srcset('default')",
"src": "file.resize(32)"
}
},
"links": {
"query": "block.links.toStructure",
"select": {
"id": true,
"linkdata": {
"query": "structureItem.linkdata.toObject",
"select": {
"target": true,
"link": true
}
}
}
}
}
}
Response (only the “links” part) looks like this:
"links": [
{
"id": "0",
"linkdata": {
"target": "false",
"link": "page:\/\/mdoFSpOhgxZbZt2B"
}
}
]
How do i convert the “link” to a relative url? I tried something like this in the query:
"linkdata": {
"query": "structureItem.linkdata.toObject",
"select": {
"target": true,
"link": "objectItem.link.toPage"
}
}
Basically inspired by the “structureItem”-method.
The idea was to have the page data and work from there. but i get a “Access to non-existing property "objectItem" on array”.
Any help or hints much appreciated!