chore: update README for clarity and formatting improvements

fix: update test imports to use new package path

refactor: improve feed class structure and formatting

refactor: enhance smartfeed class for better readability

chore: streamline plugin exports for consistency

chore: update TypeScript configuration for improved compatibility

ci: add workflows for handling tag and non-tag pushes
This commit is contained in:
2025-10-31 17:07:13 +00:00
parent 29b1420b1a
commit 622b74e628
15 changed files with 8140 additions and 17157 deletions

View File

@@ -1,7 +1,9 @@
# @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:
```bash
@@ -9,9 +11,11 @@ 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:
```typescript
@@ -41,7 +45,8 @@ const feedItem: IFeedItem = {
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...',
content:
'In a recent survey, TypeScript has seen a significant increase in adoption among developers...',
};
// Add the item to the feed
@@ -51,9 +56,11 @@ myFeed.addItem(feedItem);
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:
```typescript
@@ -64,13 +71,13 @@ const mySmartfeed = new Smartfeed();
// Parsing a feed from a string
const rssString = `your RSS feed string here`;
mySmartfeed.parseFeedFromString(rssString).then(feed => {
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 => {
mySmartfeed.parseFeedFromUrl(feedUrl).then((feed) => {
console.log(feed);
});
```
@@ -78,6 +85,7 @@ mySmartfeed.parseFeedFromUrl(feedUrl).then(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.
@@ -88,7 +96,7 @@ For complete usage and all available methods, refer to the TypeScript declaratio
## License and Legal Information
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](license) file within this repository.
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](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.