dannysmith / dannyis-astro

dannyis-astro
0 stars 0 forks source link

Add Components and enrichments for use in articles #2

Open dannysmith opened 1 year ago

dannysmith commented 1 year ago

We probably already have a few components for use in MDX articles (things like BlockQuote, Callout, Checklist etc).

Add some more that we know we'll need, probably based on those available in Notion. For example...

These are simple, non-interactive Astro components which just need HTML structure and styling.

Embeds / Enriched External Links

There is another set of components which need to get data from elsewhere. These are

For these, we have a few options...

For stuff like Tweets and Youtube videos we can just take a URL and generate the normal embed code. This means they'll render in iFrames and we can't really control the styling much. But it's simple.

For the other stuff we ned to make some requests to get the data we need to "unfurl". We could either do this at build time and generate static code, or ship JS to do the work client-side. The latter has the advantage that it will always show an up-to-date title/cover image etc.

Imagine we want inline links to Notion pages like this:

Image

Which we use like this:

This is an inline link to <Notion url="PUBLICNOTIONURL"></Notion>.

Our Astro component would...

  1. Statically render a placeholder icon and placeholder text like "Notion Page".
  2. If the Notion component has text children like a normal <a>, render that instead of the placeholder.
  3. On page load, hit the URL with a tool like Unfirl to get the title and emoji.
  4. Replace the placeholders with the title and emoji.

Downsides to this

Potentially Useful Libraries