Problem/Motivation

This is a workaround for a limitation of Canvas.

Ideally, the date prop of the hero-blog component would accept a simple Y-m-d string. Unfortunately, when you're mapping a timestamp field (like created) into that prop, all you've got is a timestamp.

Canvas has a way to convert prop values (adapters) but they're not yet supported and they won't be in time for 1.0. Trying to use them will result in a crashing UI in some situations.

So we have to map the timestamp directly into the prop. Unfortunately, Twig has no way to convert a timestamp to a formatted date because it passes raw date values into strtotime(), so we'll have to implement a pre-render callback that converts this prop, if it is an integer, to a Y-m-d value that can be passed to Twig's date filter.

Issue fork mercury-3547303

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Status: Active » Fixed

Merged with @galactus86's blessing in Slack.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • phenaproxima committed efdf8327 on 1.x
    [#3547303] feat: The hero-blog component's `date` prop needs to be a...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.