Coder Social home page Coder Social logo

guichaguri / post-feed-reader Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 119 KB

Discovers and parses news, blog and podcast posts from any website

Home Page: https://www.npmjs.com/package/post-feed-reader

License: Apache License 2.0

TypeScript 100.00%
rss atom jsonfeed wordpress autodiscovery posts parser feed

post-feed-reader's People

Contributors

dependabot[bot] avatar guichaguri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fossabot dineshdb

post-feed-reader's Issues

Fix support for content on RSS feeds

I found some inconsistencies, while parsing a RSS feed the content property of a post will contains its <description> instead of the actual content.
source

Here is my proposal:

interface PostItem {
   ...
  /**
   * The item content
   *
   * `content` from Atom 1.0 and WP API
   * `content` from RSS 0.91, RSS 1.0 and RSS 2.0
   * `content_html` and `content_text` from JSON Feed 1.1
   */
  content?: PostContent;

  /**
   * The item summary or excerpt
   *
   * `summary` from Atom 1.0 and JSON Feed 1.1
   * `description` from RSS 0.91, RSS 1.0 and RSS 2.0
   * `excerpt` from WP API
   */
  summary?: PostContent;
   ...
}

Support for h-feed from Microformats2

Implement a parser for h-feed, part of the microformats2 spec.

The format could be automatically discovered by looking for a h-feed or hfeed class in the HTML body.

Although this should be relatively easy to support, it is an old format that doesn't look like it is being widely used. Statistics on usage from both sites and readers, and how it compares to other already supported formats (such as RSS) should be taken in consideration before implementing it.

Add support for pagination

It seems that pagination is supported by all formats:

  • WordPress API supports pagination as a core feature
  • Atom and RSS feeds may support pagination as described by RFC5005
  • JSON feeds may support pagination as described by the original spec (next_url)

It's definitely possible to fetch "the next page" where available. The only thing to think is how the API should be designed, here is my proposal:

// Add a property to the PostList object, which tells information about the pagination
interface PostList {
   ...
   pagination: PostListPagination;
   ...
}

interface PostListPagination {
   currentPage?: number; // Supported only by WP API
   totalPages?: number; // Supported only by WP API
   totalPosts?: number; // Supported only by WP API
   next?: DiscoveredSource; // Supported by all formats
   previous?: DiscoveredSource; // Supported by Atom/RSS and WP API
   first?: DiscoveredSource; // Supported by all formats
   last?: DiscoveredSource; // Supported by Atom/RSS and WP API
}
// Fetching the next one is as simple as fetching the first
const nextList = await getPostList(list.pagination.next);

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.