question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embedding github gists?

See original GitHub issue

I’m trying to embed a GitHub gist into a page, and I can’t seem to get it to render. Tried using the script tag that it gives me and it’s not working out (and the iframe isn’t exactly pretty, but it works). I tried using the gatsby-remark-embed-gist plugin in gatsby and I managed to get all the errors to go away, but…it still doesn’t render. Probably because it’s not using remark for markdown parsing of the pages, right?

Here’s my gatsby-config.js file:

module.exports = {
  siteMetadata: {
    siteTitle: 'macintacos',
    siteDescription: 'this is a place where I occasionally write stuff',
    siteImage: '/banner.png', // main image of the site for metadata
    siteUrl: 'https://macintacos.github.io/',
    pathPrefix: '/',
    siteLanguage: 'en',
    ogLanguage: `en_US`,
    author: 'Julian Torres', // for example - 'Ivan Ganev'
    authorDescription: 'this is a place where I occasionally write stuff', // short text about the author
    avatar: '/avatar.jpg',
    twitterSite: 'https://twitter.com/macintacos', // website account on twitter
    twitterCreator: '', // creator account on twitter
    social: [
      {
        icon: `twitter`,
        url: `https://twitter.com/macintacos`
      },
      {
        icon: `github`,
        url: `https://github.com/macintacos`
      }
    ]
  },
  plugins: [
    {
      resolve: 'gatsby-theme-chronoblog',
      options: {
        uiText: {
          // ui text fot translate
          feedShowMoreButton: 'show more',
          feedSearchPlaceholder: 'search',
          cardReadMoreButton: 'read more →',
          allTagsButton: 'all tags'
        },
        feedItems: {
          // global settings for feed items
          limit: 50,
          yearSeparator: false,
          yearSeparatorSkipFirst: true,
          contentTypes: {
            links: {
              beforeTitle: '🔗 '
            }
          }
        },
        feedSearch: {
          symbol: '🔍'
        }
      }
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `Chronoblog Gatsby Theme`,
        short_name: `Chronoblog`,
        start_url: `/`,
        background_color: `#fff`,
        theme_color: `#3a5f7d`,
        display: `standalone`,
        icon: `src/assets/favicon.png`
      }
    },
    {
      resolve: `gatsby-plugin-sitemap`
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-embed-gist',
            options: {
              // Optional:

              // the github handler whose gists are to be accessed
              username: 'weirdpattern',

              // a flag indicating whether the github default gist css should be included or not
              // default: true
              includeDefaultCss: true
            }
          }
        ]
      }
    }
  ]
};

Any help would be greatly appreciated! Thanks!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ganevdevcommented, Jan 5, 2020

So, the problem is that - Chronoblog uses plugin “gatsby-plugin-mdx”, and does not use the plugin “gatsby-transformer-remark”. The “gatsby-plugin-mdx” plugin itself can work with remark plugins, but they must be declared in “gatsby-plugin-mdx”.

That is, I could just add “gatsby-remark-embed-gist” directly to the theme. But of course, I don’t want to pull all possible “remark” plugins into the project.

You can not declare “gatsby-plugin-mdx” in the starter - gatsby does not like it and it gives an error.

So far I see only one solution - try to make an option in Chronoblog, something like gatsbyRemarkPlugins, it should be an array that will be sent to the gatsbyRemarkPlugins option inside “gatsby-plugin-mdx” plugin.

However, maybe there is a more elegant solution? Some more standard way? I want to better explore this issue before adding new options.

0reactions
ganevdevcommented, Feb 16, 2020

Where is exacly you advise to add option gatsbyRemarkPlugins? I tried to add it as option of plugin gatsby-plugin-mdx and it’s make error with already declared _frontmatter variable.

Sorry, I probably accidentally confused you 😓.

This was a reflection on how, perhaps, it would be possible to implement this feature in the project (gatsby-theme-chronoblog), and not an instruction on what to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating gists - GitHub Docs
You can embed a gist in any text field that supports Javascript, such as a blog post. To get the embed code, click...
Read more >
Embedded Gists - The GitHub Blog
Okay, this is obvious: you can now embed gists directly into your website, blog, project overview, myspace page, whatever.
Read more >
Embed GitHub gists in Medium posts: Step-by-step guide
Go to the gist. On the upper right-hand side there is a panel with “What do you want to do?”. Click on this...
Read more >
Embed Code into your blog - and also on Medium
Embed single file of a Gist ... So by default, embedding GitHub Gists adds all files to be listed below each other. However,...
Read more >
Embed a GitHub Gist Code Snippet in a Medium Article
GitHub Gist Setup ... Navigate to https://github.com and sign up for a new account or login. ... Fill up the required fields Description...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found