"Cannot read properties of undefined (reading 'URL'):

Created on 11 November 2024, about 1 month ago

Problem/Motivation

testing basic SDC + Storybook implementation
I am getting "Cannot read properties of undefined (reading 'URL')

Steps to reproduce

I am using barebone Drupal 10.3.3 card as test component of Umami theme

card.twig

{# themes/custom/mytheme/components/card/card.twig #}
<div class="card-component">
  <h2>{{ card_title }}</h2>
  <div class="card-text">{{ card_text | raw }}</div>
  {% if card_link is defined and card_link.url %}
    <a href="{{ card_link.url }}" class="ali-link">{{ card_link.title }}</a>
  {% endif %}
</div>

card.stories.json

$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json
title: 'Card Component'
status: true
description: 'A simple example component for Drupal Storybook.'
hidden: false
fields:
  title:
    type: string
    label: 'Title'
  description:
    type: string
    label: 'Description'
  link:
    type: link
    label: 'Link'
    fields:
      title:
        type: string
        label: 'Link Title'
      url:
        type: string
        label: 'Link URL'

card.component.yml

# This is so your IDE knows about the syntax for fixes and autocomplete.
$schema: https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json

# The human readable name.
name: Card

# Status can be: "experimental", "stable", "deprecated", "obsolete".
status: experimental

# Schema for the props. We support www.json-schema.org. Learn more about the
# syntax there.
props:
  type: object
  properties:
    attributes:
      type: Drupal\Core\Template\Attribute
      title: Attributes
      description: Wrapper attributes.
    html_tag:
      type: string
      title: HTML tag for wrapper

      # Limit the available options by using enums.
      enum:
        - article
        - div
      # Provide a default value
      default: article

# Slots always hold arbitrary markup. We know that beforehand, so no need for
# a schema for slots.
slots:
  # The key is the name of the slot. In your template you will use
  # {% block content %}.
  content:
    title: Content
    required: true
    description: The card content.
<h3 id="summary-proposed-resolution">Proposed resolution</h3>


<h3 id="summary-remaining-tasks">Remaining tasks</h3>


<h3 id="summary-ui-changes">User interface changes</h3>


<h3 id="summary-api-changes">API changes</h3>


<h3 id="summary-data-model-changes">Data model changes</h3>
πŸ’¬ Support request
Status

Active

Version

1.0

Component

Storybook

Created by

πŸ‡ΊπŸ‡ΈUnited States adanbouzoua

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024