@sftech/ng-news
v0.0.3
Published
Angular library for consuming the ai-news API and displaying articles in a paginated list.
Readme
@sftech/ng-news
Angular library for consuming the ai-news API and displaying articles in a paginated list.
Installation
npm install @sftech/ng-newsConfiguration
Add NewsModule.forRoot() to your app.config.ts:
import { NewsModule } from '@sftech/ng-news';
export function appConfig(config: IAppConfig): ApplicationConfig {
return {
providers: [
// ...other providers
importProvidersFrom(NewsModule.forRoot(config)),
],
};
}Add the NEWS_API_URL to your configuration file (e.g., config.json):
{
"NEWS_API_URL": "http://localhost:3000"
}Routing
Add the news routes to your application:
import { Route } from '@angular/router';
export const appRoutes: Route[] = [
// ...other routes
{
path: 'news',
loadChildren: () => import('@sftech/ng-news').then((m) => m.newsRoutes),
},
];Features
- Paginated article list using OData queries
- Configurable API URL via application configuration
- German UI labels (consistent with existing codebase)
- Based on
ng-sharedbase components (BaseListComponent,BaseDbApiService) - PrimeNG table with responsive columns
- Article titles link to original source URLs
Article Fields
| Field | Description |
|-------|-------------|
| title | Article title (links to original URL) |
| source | News source |
| publishedAt | Publication date |
| summaryShort | Short summary |
| summary | Full summary |
| summaryEli5 | Simple explanation |
| url | Original article URL |
| tags | Article tags |
Dependencies
@angular/common>= 19.0.0@angular/core>= 19.0.0@sftech/ng-shared>= 1.0.0- PrimeNG (Table, Panel components)
API Requirements
The library expects the ai-news API to be running and accessible at the configured NEWS_API_URL.
Required Endpoint:
GET /articles/odata- Returns paginated articles with OData query support
Response Format:
{
status: number;
data: {
items: ArticleResponseDto[];
pagination: {
totalPages: number;
pageSize: number;
totalElements: number;
page: number;
isFirstPage: boolean;
isLastPage: boolean;
};
};
}Development
Build
npx nx build ng-newsTest
npx nx test ng-newsLint
npx nx lint ng-newsLicense
MIT
