Get started with gist-embed CDN

BSD-2-Clause licensed

The Gist-Embed library enables inline display of GitHub Gists within web pages.

Tags:
  • gist
  • github
  • blog
  • syntax
  • highlighting

Stable version

Copied!

How to start using gist-embed CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with gist-embed CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/gist-embed/2.7.1/gist-embed.min.js"></script>
</head>
<body>
    <div id="gist-container"></div>

    <script>
        const gistId = 'your-gist-id'; // Replace with your GitHub Gist ID
        const filePath = 'your-file-path'; // Replace with your GitHub Gist file path

        Gist.getFile(gistId, filePath, function(error, content) {
            if (error) {
                console.error('Error fetching gist:', error);
                return;
            }

            const container = document.getElementById('gist-container');
            const iframe = document.createElement('iframe');

            iframe.src = `https://gist.github.com/${gistId}/${filePath}`;
            iframe.width = '100%';
            iframe.height = '500px';
            iframe.frameBorder = '0';
            iframe.title = 'Gist';
            iframe.allowFullscreen = true;

            container.appendChild(iframe);
        });
    </script>
</body>
</html>
Copied!
Copied!
Copied!

All versions