Scott Watermasysk
Next.js to Ruby
I have been working on converting something from Next.js to Ruby. The Next.js version is still more visually appealing to me, but the benefits of working in Ruby far supior to me long term.
Before:
<Card as="article">
<Card.Title href={`/articles/${article.slug}`}>
{article.title}
</Card.Title>
<Card.Eyebrow as="time" dateTime={article.date} decorate>
{formatDate(article.date)}
</Card.Eyebrow>
<Card.Description>{article.description}</Card.Description>
<Card.Cta>Read article</Card.Cta>
</Card>
After:
{%@ Shared::Card::Card as: :article do %}
{%@ Shared::Card::Title as: :h2, href: article.relative_url do %}
{{article.data.title}}
{% end %}
{%@ Shared::Card::Eyebrow as: :time, dateTime: article.data.date, decorate: true do %}
{{article.data.date}}
{% end %}
{%@ Shared::Card::Description do %}
{{article.data.description}}
{% end %}
{%@ Shared::Card::Cta do %}Read article{% end %}
{% end %}