@fedify/astro 2.4.0-pr.934.40 → 2.4.0
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 +41 -5
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -10,19 +10,31 @@
|
|
|
10
10
|
*This package is available since Fedify 2.1.0.*
|
|
11
11
|
|
|
12
12
|
This package provides a simple way to integrate [Fedify] with [Astro].
|
|
13
|
+
Astro 5, 6, and 7 are supported.
|
|
14
|
+
|
|
15
|
+
Fedify needs Astro's on-demand rendering, so install a server adapter for your
|
|
16
|
+
runtime. The following Node.js configuration uses `@astrojs/node` 11 with
|
|
17
|
+
Astro 7:
|
|
13
18
|
|
|
14
19
|
First, add the integration to your *astro.config.mjs*:
|
|
15
20
|
|
|
16
21
|
~~~~ typescript
|
|
17
22
|
import { defineConfig } from "astro/config";
|
|
18
23
|
import { fedifyIntegration } from "@fedify/astro";
|
|
24
|
+
import node from "@astrojs/node";
|
|
19
25
|
|
|
20
26
|
export default defineConfig({
|
|
21
27
|
integrations: [fedifyIntegration()],
|
|
22
28
|
output: "server",
|
|
29
|
+
adapter: node({ mode: "standalone" }),
|
|
23
30
|
});
|
|
24
31
|
~~~~
|
|
25
32
|
|
|
33
|
+
The `"server"` output is the simplest default because Fedify handles endpoints
|
|
34
|
+
such as WebFinger and inboxes that do not have corresponding Astro page files.
|
|
35
|
+
Individual Astro pages can still opt into prerendering with
|
|
36
|
+
`export const prerender = true`.
|
|
37
|
+
|
|
26
38
|
Then, create your middleware in *src/middleware.ts*:
|
|
27
39
|
|
|
28
40
|
~~~~ typescript
|
|
@@ -39,6 +51,23 @@ export const onRequest = fedifyMiddleware(
|
|
|
39
51
|
);
|
|
40
52
|
~~~~
|
|
41
53
|
|
|
54
|
+
If your application has other middleware, compose it with the Fedify
|
|
55
|
+
middleware using `sequence()`:
|
|
56
|
+
|
|
57
|
+
~~~~ typescript
|
|
58
|
+
import { fedifyMiddleware } from "@fedify/astro";
|
|
59
|
+
import type { MiddlewareHandler } from "astro";
|
|
60
|
+
import { sequence } from "astro:middleware";
|
|
61
|
+
import federation from "./federation.ts";
|
|
62
|
+
|
|
63
|
+
const otherMiddleware: MiddlewareHandler = (_context, next) => next();
|
|
64
|
+
|
|
65
|
+
export const onRequest = sequence(
|
|
66
|
+
otherMiddleware,
|
|
67
|
+
fedifyMiddleware(federation, () => undefined),
|
|
68
|
+
);
|
|
69
|
+
~~~~
|
|
70
|
+
|
|
42
71
|
[JSR badge]: https://jsr.io/badges/@fedify/astro
|
|
43
72
|
[JSR]: https://jsr.io/@fedify/astro
|
|
44
73
|
[npm badge]: https://img.shields.io/npm/v/@fedify/astro?logo=npm
|
|
@@ -52,6 +81,12 @@ export const onRequest = fedifyMiddleware(
|
|
|
52
81
|
For Deno users
|
|
53
82
|
--------------
|
|
54
83
|
|
|
84
|
+
`@fedify/astro` remains available on JSR, but Deno-based Astro projects should
|
|
85
|
+
install it and the other packages loaded by Astro from npm. Astro loads
|
|
86
|
+
integrations and middleware through Vite, which resolves bare imports through
|
|
87
|
+
*node\_modules/* rather than Deno's JSR import map. The npm specifiers let Deno
|
|
88
|
+
populate *node\_modules/* for Vite.
|
|
89
|
+
|
|
55
90
|
If you are using Deno, you should import `@deno/astro-adapter` in
|
|
56
91
|
*astro.config.mjs* and use it as the adapter:
|
|
57
92
|
|
|
@@ -84,18 +119,19 @@ instead of `astro`:
|
|
|
84
119
|
For Bun users
|
|
85
120
|
-------------
|
|
86
121
|
|
|
87
|
-
|
|
88
|
-
Astro
|
|
122
|
+
Astro 7 does not have a compatible Bun-specific adapter. The tested Bun
|
|
123
|
+
configuration uses `@astrojs/node` 11 in standalone mode, builds Astro with
|
|
124
|
+
Bun, and runs the resulting server entry point with Bun:
|
|
89
125
|
|
|
90
126
|
~~~~ typescript
|
|
91
127
|
import { defineConfig } from "astro/config";
|
|
92
128
|
import { fedifyIntegration } from "@fedify/astro";
|
|
93
|
-
import
|
|
129
|
+
import node from "@astrojs/node";
|
|
94
130
|
|
|
95
131
|
export default defineConfig({
|
|
96
132
|
integrations: [fedifyIntegration()],
|
|
97
133
|
output: "server",
|
|
98
|
-
adapter:
|
|
134
|
+
adapter: node({ mode: "standalone" }),
|
|
99
135
|
});
|
|
100
136
|
~~~~
|
|
101
137
|
|
|
@@ -139,7 +175,7 @@ Installation
|
|
|
139
175
|
------------
|
|
140
176
|
|
|
141
177
|
~~~~ sh
|
|
142
|
-
deno add
|
|
178
|
+
deno add npm:@fedify/astro # Deno
|
|
143
179
|
npm add @fedify/astro # npm
|
|
144
180
|
pnpm add @fedify/astro # pnpm
|
|
145
181
|
yarn add @fedify/astro # Yarn
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/astro",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Integrate Fedify with Astro",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
"package.json"
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"astro": "^5.0.0",
|
|
50
|
-
"@fedify/fedify": "^2.4.0
|
|
49
|
+
"astro": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
50
|
+
"@fedify/fedify": "^2.4.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"astro": "^7.0.0",
|
|
53
54
|
"tsdown": "^0.22.0",
|
|
54
55
|
"typescript": "^6.0.0"
|
|
55
56
|
},
|