-
-
Save digitalmud/4734631 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Add <ul id=”recent-posts”></ul> to your blog to demark where you'd like the list to appear. | |
| // | |
| // Needs jQuery. Place the javascript below *after* your jQuery include. | |
| <script type="text/javascript"> | |
| $(function() { | |
| // This script uses your tumble blog's RSS feed. The URL is usually in the form yoursite.tumblr.com/rss | |
| var url = '/rss'; | |
| var $list = $('#recent-posts'); | |
| $.ajax({ | |
| url: url, | |
| type: 'GET', | |
| dataType: 'xml', | |
| success: function(data) { | |
| var $items = $(data).find('item'); | |
| $items.each( function() { | |
| var $item = $(this); | |
| var link = $item.children('link').text(); | |
| var title = $item.children('title').text(); | |
| if (link && title) { | |
| $list.append($('<li><a href="' + link + '">' + title + '</a></li>')); | |
| } | |
| }); | |
| } | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I'm totally new to both JS and GitHub. Can you tell me how to make this thing work only for 5 posts? I mean, there must be some way to limit the function(data) call to 5 posts only... but I dont know where to get that thing done. Would be great if you could help me out :) Thanks :)