Comment

Comment by Pitarou

Is there an easy way to do represent something like this in Cell:

    <p>I will say this <em>emphatically</em></p>
As far as I can tell, Cell doesn’t permit this. If you have multiple child nodes ($components), none of them can be text nodes, so you have to work around it like this:

    <p><span>I will say this </span><em>emphatically</em></p>
Why not do away with the $text keyword entirely, and treat any strings in the $components list as text nodes? So instead of this:

    $text: "Buy now!!".
you have this:

    $components: ["Buy now!!"],
and instead of this:

    $components: [
      {$type: "span", $text: "Buy "},
      {$type: "em", $text: "now!!},
    ],
you have this:

    $components: [
      "Buy ",
      {$type: "em", $text: "now!!},
    ],
parent Pitarou 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton