Skip to content

Commit 7c9311d

Browse files
Added new readme
1 parent 1c109eb commit 7c9311d

File tree

3 files changed

+68
-18
lines changed

3 files changed

+68
-18
lines changed

README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,54 @@ A TypeScript library for generating **OPDS feeds** (v1.2) with a fluent API. Des
1111
- Relative URL resolution to absolute URLs.
1212
- Support for extra metadata / vendor-specific attributes.
1313
- Output as pretty or compact XML.
14-
- Helpers for common OPDS links (`self`, `start`).
14+
- Parse from XML.
15+
- Helpers for common OPDS links like navigation or acquisition.
1516

1617
## Installation
1718

1819
```bash
1920
npm install opds-ts
2021
```
2122

23+
## Importing
24+
25+
When importing make sure to use the right version. E.g.:
26+
27+
```ts
28+
import { Feed, Entry } from 'opds-ts/v1.2';
29+
```
30+
31+
or
32+
33+
```ts
34+
import * as opdsv2 from 'opds-ts/v2';
35+
```
36+
2237
## Basic usage
2338

24-
This is an example on how to create a simple feed:
39+
This is an example on how to create a simple v1.2 feed:
2540

2641
```ts
27-
import { Feed } from 'opds-ts';
28-
import { Entry } from 'opds-ts';
42+
import { Feed, Entry } from 'opds-ts/v1.2';
2943

3044
const baseUrl = 'https://example.com';
3145

3246
const feed = new Feed('books', 'All Books')
3347
.setLang('en')
3448
.setAuthor('The Library of Babel')
3549
.setKind('navigation')
36-
.addSelfLink('/opds', 'navigation')
37-
.addStartLink('/opds');
50+
.addNavigationLink('start', '/opds');
3851

3952
const entry = new Entry('book:1', 'The Lord of the Rings')
4053
.setAuthor('J. R. R. Tolkien')
4154
.setSummary(
4255
'A ring with mysterious powers lands in the hands of a young hobbit, Frodo. Under the guidance of Gandalf, a wizard, he and his three friends set out on a journey and land in the Elvish kingdom.'
4356
)
44-
.addAcquisition('/entry/1/acquisition', 'application/epub+zip')
57+
.addAcquisition(
58+
'/entry/1/acquisition',
59+
'application/epub+zip',
60+
'open-access'
61+
)
4562
.addImage('/data/covers/1.jpg');
4663

4764
feed.addEntry(entry);
@@ -50,6 +67,16 @@ const xml = feed.toXml({ baseUrl, prettyPrint: true });
5067
console.log(xml);
5168
```
5269

70+
This is an example on how to parse a v1.2 feed:
71+
72+
```ts
73+
import { Feed } from 'opds-ts/v1.2';
74+
75+
const xmlString = '...';
76+
const feed = Feed.fromXml(xmlString);
77+
console.log(feed.getEntries());
78+
```
79+
5380
## License
5481

5582
This project is licensed under the MIT License - see the [LICENSE](https://github.com/KartoffelChipss/Typerinth/blob/main/LICENSE) file for details.

src/index.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

typedoc-readme.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,54 @@ A TypeScript library for generating **OPDS feeds** (v1.2) with a fluent API. Des
99
- Relative URL resolution to absolute URLs.
1010
- Support for extra metadata / vendor-specific attributes.
1111
- Output as pretty or compact XML.
12-
- Helpers for common OPDS links (`self`, `start`).
12+
- Parse from XML.
13+
- Helpers for common OPDS links like navigation or acquisition.
1314

1415
## Installation
1516

1617
```bash
1718
npm install opds-ts
1819
```
1920

21+
## Importing
22+
23+
When importing make sure to use the right version. E.g.:
24+
25+
```ts
26+
import { Feed, Entry } from 'opds-ts/v1.2';
27+
```
28+
29+
or
30+
31+
```ts
32+
import * as opdsv2 from 'opds-ts/v2';
33+
```
34+
2035
## Basic usage
2136

22-
This is an example on how to create a simple feed:
37+
This is an example on how to create a simple v1.2 feed:
2338

2439
```ts
25-
import { Feed } from 'opds-ts';
26-
import { Entry } from 'opds-ts';
40+
import { Feed, Entry } from 'opds-ts/v1.2';
2741

2842
const baseUrl = 'https://example.com';
2943

3044
const feed = new Feed('books', 'All Books')
3145
.setLang('en')
3246
.setAuthor('The Library of Babel')
3347
.setKind('navigation')
34-
.addSelfLink('/opds', 'navigation')
35-
.addStartLink('/opds');
48+
.addNavigationLink('start', '/opds');
3649

3750
const entry = new Entry('book:1', 'The Lord of the Rings')
3851
.setAuthor('J. R. R. Tolkien')
3952
.setSummary(
4053
'A ring with mysterious powers lands in the hands of a young hobbit, Frodo. Under the guidance of Gandalf, a wizard, he and his three friends set out on a journey and land in the Elvish kingdom.'
4154
)
42-
.addAcquisition('/entry/1/acquisition', 'application/epub+zip')
55+
.addAcquisition(
56+
'/entry/1/acquisition',
57+
'application/epub+zip',
58+
'open-access'
59+
)
4360
.addImage('/data/covers/1.jpg');
4461

4562
feed.addEntry(entry);
@@ -48,6 +65,16 @@ const xml = feed.toXml({ baseUrl, prettyPrint: true });
4865
console.log(xml);
4966
```
5067

68+
This is an example on how to parse a v1.2 feed:
69+
70+
```ts
71+
import { Feed } from 'opds-ts/v1.2';
72+
73+
const xmlString = '...';
74+
const feed = Feed.fromXml(xmlString);
75+
console.log(feed.getEntries());
76+
```
77+
5178
## License
5279

5380
This project is licensed under the MIT License - see the [LICENSE](https://github.com/KartoffelChipss/Typerinth/blob/main/LICENSE) file for details.

0 commit comments

Comments
 (0)