A library for creating and parsing various feed formats.
Go to file
2024-04-14 17:35:04 +02:00
.vscode fix(core): update 2020-10-25 00:09:33 +00:00
test fix(core): update 2020-11-11 10:11:18 +00:00
ts fix(core): update 2020-11-28 14:38:04 +00:00
.gitignore fix(core): update 2020-10-25 00:09:33 +00:00
.gitlab-ci.yml fix(core): update 2020-10-25 00:09:33 +00:00
license fix(core): update 2020-10-25 00:09:33 +00:00
npmextra.json update tsconfig 2024-04-14 17:35:04 +02:00
package-lock.json 1.0.11 2020-12-10 17:33:02 +00:00
package.json update tsconfig 2024-04-14 17:35:04 +02:00
pnpm-lock.yaml switch to new org scheme 2023-07-11 00:40:27 +02:00
readme.hints.md update tsconfig 2024-04-14 17:35:04 +02:00
readme.md update tsconfig 2024-04-14 17:35:04 +02:00
tsconfig.json update npmextra.json: githost 2024-04-01 21:34:58 +02:00

@push.rocks/smartfeed

create and parse feeds

Install

To install @push.rocks/smartfeed, you need to have Node.js installed on your machine. After setting up Node.js, run the following command in your terminal:

npm install @push.rocks/smartfeed --save

Usage

@push.rocks/smartfeed is a powerful library for creating and parsing RSS and Atom feeds with ease. It leverages TypeScript for type safety and improved developer experience. Let's explore how you can utilize this library in your projects.

Creating Feeds

You can create feeds by instantiating a Smartfeed object and configuring feed options and items. Heres an example of how to create an RSS feed:

import { Smartfeed, IFeedOptions, IFeedItem } from '@push.rocks/smartfeed';

// Create a new Smartfeed instance
const mySmartfeed = new Smartfeed();

// Define feed options
const feedOptions: IFeedOptions = {
  domain: 'example.com',
  title: 'Example News',
  description: 'Latest news from Example',
  category: 'News',
  company: 'Example Company',
  companyEmail: 'contact@example.com',
  companyDomain: 'https://example.com',
};

// Create a new feed with options
const myFeed = mySmartfeed.createFeed(feedOptions);

// Add items to the feed
const feedItem: IFeedItem = {
  title: 'Breaking News: TypeScript Adoption Soars!',
  timestamp: Date.now(), // Use current timestamp
  url: 'https://example.com/news/typescript-adoption',
  authorName: 'Jane Doe',
  imageUrl: 'https://example.com/images/typescript-news.jpg',
  content: 'In a recent survey, TypeScript has seen a significant increase in adoption among developers...',
};

// Add the item to the feed
myFeed.addItem(feedItem);

// Export the feed as an RSS string
const rssFeedString = myFeed.exportRssFeedString();
console.log(rssFeedString);

This code snippet creates an RSS feed for a news article. You can customize the IFeedOptions and IFeedItem objects to match your content.

Parsing Feeds

@push.rocks/smartfeed also allows parsing of RSS and Atom feeds from a string or URL. Heres how you can parse a feed:

import { Smartfeed } from '@push.rocks/smartfeed';

// Create a new Smartfeed instance
const mySmartfeed = new Smartfeed();

// Parsing a feed from a string
const rssString = `your RSS feed string here`;
mySmartfeed.parseFeedFromString(rssString).then(feed => {
  console.log(feed);
});

// Parsing a feed from a URL
const feedUrl = 'https://example.com/rss';
mySmartfeed.parseFeedFromUrl(feedUrl).then(feed => {
  console.log(feed);
});

This example demonstrates how to parse an RSS feed from a given string or URL. The parseFeedFromString and parseFeedFromUrl methods return a Promise that resolves to the parsed feed object.

Comprehensive Feed Management

With @push.rocks/smartfeed, you have full control over creating and managing feeds. Beyond basic scenarios shown above, you can create feeds from arrays of articles, customize feed and item properties extensively, and export feeds in different formats (RSS, Atom, JSON).

For instance, to create a feed from an array of article objects conforming to @tsclass/tsclass's IArticle interface, you can use the createFeedFromArticleArray method. Additionally, explore different export options available on the Feed class to suit your needs, whether it's RSS 2.0, Atom 1.0, or JSON Feed 1.0.

Remember, @push.rocks/smartfeed is designed to streamline feed creation and parsing with a focus on type safety and developer experience. Explore its comprehensive API to leverage the full potential of feed management in your applications.

For complete usage and all available methods, refer to the TypeScript declarations and source code available in the package. Happy coding!

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the license file within this repository.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

Company Information

Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.