Coder Social home page Coder Social logo

Comments (6)

delucis avatar delucis commented on September 21, 2024

How are you rendering your MDX content?

As a general answer, YouTube embeds require JavaScript, which isn’t supported in RSS feeds. I think the closest result you could get would be to render an image which links to YouTube, but I’d need to know more about your set-up to advise further.

from astro-embed.

johannesholmberg avatar johannesholmberg commented on September 21, 2024

Thanks for getting back.

This is my rss.xml.js:

import rss from '@astrojs/rss'
import MarkdownIt from 'markdown-it'
const parser = new MarkdownIt()
import { getCollection } from 'astro:content'
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'

export async function get(context) {
  const posts = await getCollection('posts')
  return rss({
    title: SITE_TITLE,
    description: SITE_DESCRIPTION,
    site: context.site,
    items: posts.map((post) => ({
      ...post.data,
      link: `/posts/${post.slug}/`,
      content: parser.render(post.body),
    })),
  })
}

I’ve seen feeds which have YouTube embeds and I can watch them directly in my RSS reader.

from astro-embed.

delucis avatar delucis commented on September 21, 2024

Ah, ok, so in this case you'd need a way to tell markdown-it how to render the embed.

But first, you'd need to work out what it should generate. Can you share an example RSS feed with an embedded video to see what markup it includes?

from astro-embed.

johannesholmberg avatar johannesholmberg commented on September 21, 2024

I think this is what we’re looking for:

CleanShot 2023-09-21 at 10 12 28@2x

Source: https://css-irl.info/rss.xml (search for iframe)

from astro-embed.

delucis avatar delucis commented on September 21, 2024

OK, so that’s the standard YouTube <iframe> code. That should be possible to generate, but your parser.render() method would need to know how to do that, i.e. find <YouTube id="xtTy5nKay_Y" /> and convert it to:

<iframe width="560" height="315" src="https://www.youtube.com/embed/xtTy5nKay_Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

As far as I can tell that’s a simple mapping of the id to the last part of the URL in src attribute of the <iframe>. I’m not familiar with how markdown-it plugins work, so not sure exactly you’d do the transformation.

from astro-embed.

delucis avatar delucis commented on September 21, 2024

Closing this issue as out of scope for this repository. Thanks again for opening @johannesholmberg!

from astro-embed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.