Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body class="bg-light">
<div class="container mt-5 pt-5" id="medium">
        <div class="jumbotron text-center">
            <div id="logo"></div>
            <h1 class="display-4 mb-3">@mediumstaff's Posts</h1>
            <a class="btn btn-outline-primary btn-lg" href="https://medium.com/@mediumstaff" target="_blank" role="button">View all posts</a>
        </div>
        <div class="row" id="jsonContent">
        </div>
    </div>


        <ul id="pagin" class="pagination justify-content-center">
        </ul>

    <div class="text-center">
        <div class="mb-5">
            <a class="btn btn-outline-primary btn-lg mb-5" href="https://medium.com/@mediumstaff">View all Posts</a>
        </div>
    </div>
</body>
              
            
!

CSS

              
                
              
            
!

JS

              
                 $(function () {
            var mediumPromise = new Promise(function (resolve) {
            var $content = $('#jsonContent');
            var data = {
                rss: 'https://medium.com/feed/@mediumstaff'
            };
            $.get('https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fmedium.com%2Ffeed%2F%40mediumstaff', data, function (response) {
                if (response.status == 'ok') {
                    $("#logo").append(`<img src="${response.feed["image"]}" class="rounded mx-auto d-block">`)
                    var output = '';
                    $.each(response.items, function (k, item) {
                        output += `<div class="card mb-3 mx-auto mr-5 " style="width: 20rem;">`;
                        var tagIndex = item.description.indexOf('<img'); // Find where the img tag starts
                        var srcIndex = item.description.substring(tagIndex).indexOf('src=') + tagIndex; // Find where the src attribute starts
                        var srcStart = srcIndex + 5; // Find where the actual image URL starts; 5 for the length of 'src="'
                        var srcEnd = item.description.substring(srcStart).indexOf('"') + srcStart; // Find where the URL ends
                        var src = item.description.substring(srcStart, srcEnd); // Extract just the URL
                        output += `<img src="${src}" class="card-img-top" alt="Cover image">`;
                        output += `<div class="card-body">`;
                        output += `<h5 class="card-title"><a href="${item.link}">${item.title}</a></h5>`;
                        var yourString = item.description.replace(/<img[^>]*>/g,""); //replace with your string.
                        yourString = yourString.replace('h4', 'p');
                        yourString = yourString.replace('h3', 'p');
                        var maxLength = 120; // maximum number of characters to extract
                        //trim the string to the maximum length
                        var trimmedString = yourString.substr(0, maxLength);
                        //re-trim if we are in the middle of a word
                        trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")))
                        output += `<p class="card-text">${trimmedString}...</p>`;
                        output += `<a href="${item.link}" class="btn btn-outline-success">Read More</a>`;
                        output += '</div></div>';
                        return k < 10;
                    });
                    resolve($content.html(output));
                }
            });
            });

mediumPromise.then(function()
            {
                //Pagination
                pageSize = 3;

                var pageCount = $(".card").length / pageSize;

                for (var i = 0; i < pageCount; i++) {
                    $("#pagin").append(`<li class="page-item"><a class="page-link" href="#">${(i + 1)}</a></li> `);
                }
                $("#pagin li:nth-child(1)").addClass("active");
                showPage = function (page) {
                    $(".card").hide();
                    $(".card").each(function (n) {
                        if (n >= pageSize * (page - 1) && n < pageSize * page)
                            $(this).show();
                    });
                }

                showPage(1);

                $("#pagin li").click(function () {
                    $("#pagin li").removeClass("active");
                    $(this).addClass("active");
                    showPage(parseInt($(this).text()))
                });
            });
        });



              
            
!
999px

Console