webring 1.10.0-dev.9107 → 1.10.0-dev.9112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://
|
|
4
|
-
<source media="(prefers-color-scheme: light)" srcset="https://
|
|
5
|
-
<img alt="webring logo" src="https://
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/shepherdjerred/monorepo/main/packages/webring/assets/logo-dark.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/shepherdjerred/monorepo/main/packages/webring/assets/logo-light.png">
|
|
5
|
+
<img alt="webring logo" src="https://raw.githubusercontent.com/shepherdjerred/monorepo/main/packages/webring/assets/logo-light.png" height=150>
|
|
6
6
|
</picture>
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/webring)
|
|
@@ -27,7 +27,7 @@ npm i webring
|
|
|
27
27
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
30
|
-
This library is intended to be used with a static site generator. I use
|
|
30
|
+
This library is intended to be used with a static site generator. I use it with [Astro](https://astro.build/) on my personal website — see [`packages/sjer.red/src/webring.ts`](https://github.com/shepherdjerred/monorepo/blob/main/packages/sjer.red/src/webring.ts) for a real consumer.
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { run } from "webring";
|
|
@@ -47,6 +47,8 @@ const result = await run({
|
|
|
47
47
|
title: "Jake Lazaroff",
|
|
48
48
|
},
|
|
49
49
|
],
|
|
50
|
+
number: 3,
|
|
51
|
+
truncate: 300,
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
console.log(result);
|
|
@@ -80,13 +82,33 @@ console.log(result);
|
|
|
80
82
|
|
|
81
83
|
## Configuration
|
|
82
84
|
|
|
83
|
-
`webring` is configured by passing
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
`webring` is configured by passing a `Configuration` object into `run`. The
|
|
86
|
+
exported `Configuration` type is the Zod _output_ type, so the schema's
|
|
87
|
+
defaults for `number` and `truncate` are already applied in the type: those two
|
|
88
|
+
fields are **required** on the object you pass in, alongside `sources`. Only
|
|
89
|
+
`cache` and `shuffle` may be omitted.
|
|
90
|
+
|
|
91
|
+
| Key | Type | Required | Description |
|
|
92
|
+
| ------------------------------ | -------------------- | -------- | --------------------------------------------------------------------- |
|
|
93
|
+
| `sources` | `Source[]` | yes | Feeds to fetch. Each has a `url`, a `title`, and an optional `filter` |
|
|
94
|
+
| `number` | `number` | yes | Return the n latest updates across all sources |
|
|
95
|
+
| `truncate` | `number` | yes | Preview length in characters, applied after HTML sanitization |
|
|
96
|
+
| `cache` | `CacheConfiguration` | no | Enable caching by providing this object; omit it to disable caching |
|
|
97
|
+
| `cache.cache_file` | `string` | no | File used as the cache. Defaults to `"cache.json"` |
|
|
98
|
+
| `cache.cache_duration_minutes` | `number` | no | How long a cached result is reused. Defaults to `60` |
|
|
99
|
+
| `shuffle` | `boolean` | no | Randomize the output order. Omitted behaves as `false` |
|
|
100
|
+
|
|
101
|
+
The `cache.*` defaults above are the only ones `run` fills in at runtime: it
|
|
102
|
+
parses the object with `CachedConfigurationSchema`, which succeeds only when
|
|
103
|
+
`cache` is present. Without a `cache` key the object is used as given, so
|
|
104
|
+
`number` and `truncate` must carry real values rather than relying on the
|
|
105
|
+
schema.
|
|
106
|
+
|
|
107
|
+
Full generated API documentation: [webring.sjer.red](https://webring.sjer.red) (e.g. [`Configuration`](https://webring.sjer.red/types/Configuration.html)).
|
|
86
108
|
|
|
87
109
|
## Example
|
|
88
110
|
|
|
89
|
-
An example of using this project with Astro is located in `example`. The relevant file is [`src/pages/blog/[...slug].astro`](https://github.com/shepherdjerred/monorepo/blob/main/packages/webring/example/src/pages/blog/%5B...slug%5D.astro
|
|
111
|
+
An example of using this project with Astro is located in `example`. The relevant file is [`src/pages/blog/[...slug].astro`](https://github.com/shepherdjerred/monorepo/blob/main/packages/webring/example/src/pages/blog/%5B...slug%5D.astro).
|
|
90
112
|
|
|
91
113
|
```typescript
|
|
92
114
|
---
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"url": "https://github.com/shepherdjerred/monorepo/issues"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.10.0-dev.
|
|
20
|
+
"version": "1.10.0-dev.9112",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint src --cache",
|
|
23
23
|
"build": "PATH=node_modules/@typescript/native/bin:$PATH tsc",
|