Problem/Motivation
I am trying to define a URL as a property in my component:
props:
type: object
properties:
url:
"$ref": ui-patterns://url
If I want to use this property in a story, I enter a string, which works perfectly. The string is converted into a url object as expected.
name: Button
component: "my_theme:button"
props:
url: "https://www.example.com"
the drupal uri schema does not work. Shouldn't this one be just as applicable?
name: Button
component: "my_theme:button"
props:
url: "internal:/<front>"
Now I want to use my component within Drupal. So I pass a URL object in my template (not SDC, but within e.g. node.html.twig) into my button component. However, a string is now accepted.
{%- include "my_theme:button" with {
label: 'label',
url: url,
} only -%}
Is there something wrong with this concept? I am assuming that I am transferring a URL object.
Another but related question: In addition, I want to use the Drupal link function ‘{{ link() }}’ within my component, into which I then pass my URL object. This accepts a URL object as the URL parameter, as I expect.
The sdc_devel module shows me the error:
‘Forbidden Twig function: `link`. PHP URL object, or useless if URL string.’
I would have assumed that the function within Drupal should always be used in preference to hardcoding links. Otherwise I have no possibility to process these links in processing (for example when checking permissions).
Have I not understood something about the basic concept of UI patterns? :)