@rmdes/indiekit-endpoint-micropub 1.0.0-beta.27 → 1.0.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 +146 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @rmdes/indiekit-endpoint-micropub
|
|
2
2
|
|
|
3
|
-
Micropub endpoint for Indiekit. Enables publishing content to your website using the Micropub protocol.
|
|
3
|
+
Micropub endpoint for Indiekit with custom type-based post discovery and pre-syndication markup support. Enables publishing content to your website using the [Micropub protocol](https://micropub.spec.indieweb.org/).
|
|
4
4
|
|
|
5
5
|
## Fork Notice
|
|
6
6
|
|
|
7
|
-
This is a fork of `@indiekit/endpoint-micropub` with
|
|
7
|
+
This is a fork of `@indiekit/endpoint-micropub` with two custom features:
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### 1. Pre-Syndication Markup Support
|
|
10
10
|
|
|
11
|
-
Services like IndieNews require a `u-syndication` link in your HTML **before** they receive the syndication webmention. The upstream Micropub endpoint strips all `mp-*` properties (including `mp-syndicate-to`) before passing data to the preset's `postTemplate()`.
|
|
11
|
+
Services like [IndieNews](https://news.indieweb.org/) require a `u-syndication` link in your HTML **before** they receive the syndication webmention. The upstream Micropub endpoint strips all `mp-*` properties (including `mp-syndicate-to`) before passing data to the preset's `postTemplate()`.
|
|
12
12
|
|
|
13
13
|
This fork preserves `mp-syndicate-to` so that:
|
|
14
14
|
1. The property reaches the preset's `postTemplate()`
|
|
@@ -16,9 +16,7 @@ This fork preserves `mp-syndicate-to` so that:
|
|
|
16
16
|
3. The theme can render the `u-syndication` link
|
|
17
17
|
4. IndieNews (and similar services) can find the link when parsing the webmention
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
The change is in `lib/utils.js`:
|
|
19
|
+
**Technical change** in `lib/utils.js`:
|
|
22
20
|
|
|
23
21
|
```javascript
|
|
24
22
|
// mp- properties to preserve for the template (needed for pre-syndication markup)
|
|
@@ -32,6 +30,22 @@ for (let key in templateProperties) {
|
|
|
32
30
|
}
|
|
33
31
|
```
|
|
34
32
|
|
|
33
|
+
### 2. Type-Based Post Type Discovery
|
|
34
|
+
|
|
35
|
+
The external `@paulrobertlloyd/mf2tojf2` library only preserves standard microformat properties during mf2→JF2 conversion. Custom discovery properties were being stripped, making it impossible for custom post type plugins to trigger type detection.
|
|
36
|
+
|
|
37
|
+
This fork adds a type-based discovery mechanism in `lib/post-type-discovery.js`:
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
// If post has a custom type (h value) that matches a configured post type
|
|
41
|
+
// This allows plugins to use h: "page" or similar for type-based discovery
|
|
42
|
+
if (properties.type && properties.type !== "entry" && postTypes[properties.type]) {
|
|
43
|
+
return properties.type;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This enables custom post type plugins like `@rmdes/indiekit-post-type-page` to work correctly.
|
|
48
|
+
|
|
35
49
|
## Installation
|
|
36
50
|
|
|
37
51
|
```bash
|
|
@@ -45,32 +59,143 @@ Add to your `package.json`:
|
|
|
45
59
|
```json
|
|
46
60
|
{
|
|
47
61
|
"overrides": {
|
|
48
|
-
"@indiekit/endpoint-micropub": "npm:@rmdes/indiekit-endpoint-micropub@^1.0.0-beta.
|
|
62
|
+
"@indiekit/endpoint-micropub": "npm:@rmdes/indiekit-endpoint-micropub@^1.0.0-beta.28"
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
```
|
|
52
66
|
|
|
53
67
|
This replaces the upstream package with this fork without changing your plugin configuration.
|
|
54
68
|
|
|
55
|
-
|
|
69
|
+
### Direct installation
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import MicropubEndpoint from "@rmdes/indiekit-endpoint-micropub";
|
|
73
|
+
|
|
74
|
+
export default {
|
|
75
|
+
plugins: [
|
|
76
|
+
new MicropubEndpoint({
|
|
77
|
+
mountPath: "/micropub" // Optional, defaults to /micropub
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
### Options
|
|
56
86
|
|
|
57
87
|
| Option | Type | Description |
|
|
58
88
|
| :---------- | :------- | :------------------------------------------------------------------------ |
|
|
59
|
-
| `mountPath` | `string` | Path to listen to Micropub requests.
|
|
89
|
+
| `mountPath` | `string` | Path to listen to Micropub requests. Optional, defaults to `/micropub`. |
|
|
90
|
+
|
|
91
|
+
## Supported Endpoints
|
|
92
|
+
|
|
93
|
+
### POST /micropub (Action Endpoint)
|
|
94
|
+
|
|
95
|
+
Create, update, delete, or undelete posts using the Micropub protocol.
|
|
96
|
+
|
|
97
|
+
**Actions:**
|
|
98
|
+
- `create` - Create new post (requires `create` or `post` scope)
|
|
99
|
+
- `update` - Update existing post (requires `update` scope)
|
|
100
|
+
- `delete` - Delete post (requires `delete` scope)
|
|
101
|
+
- `undelete` - Restore deleted post (requires `create` scope)
|
|
102
|
+
|
|
103
|
+
**Update operations:**
|
|
104
|
+
- `replace` - Replace entire property value
|
|
105
|
+
- `add` - Add value to existing property
|
|
106
|
+
- `delete` - Delete property or specific values
|
|
107
|
+
|
|
108
|
+
### GET /micropub (Query Endpoint)
|
|
109
|
+
|
|
110
|
+
Query published posts and configuration.
|
|
111
|
+
|
|
112
|
+
**Supported queries:**
|
|
113
|
+
|
|
114
|
+
| Query | Description | Example |
|
|
115
|
+
|-------|-------------|---------|
|
|
116
|
+
| `config` | Full configuration | `/micropub?q=config` |
|
|
117
|
+
| `media-endpoint` | Media endpoint URL | `/micropub?q=media-endpoint` |
|
|
118
|
+
| `syndicate-to` | Available syndication targets | `/micropub?q=syndicate-to` |
|
|
119
|
+
| `post-types` | Supported post types | `/micropub?q=post-types` |
|
|
120
|
+
| `category` | Publication categories | `/micropub?q=category` |
|
|
121
|
+
| `channel` | Publication channels | `/micropub?q=channel` |
|
|
122
|
+
| `source` | Published posts (paginated) | `/micropub?q=source` |
|
|
123
|
+
| `source&url=URL` | Single post by URL | `/micropub?q=source&url=https://example.com/post` |
|
|
60
124
|
|
|
61
|
-
|
|
125
|
+
**Pagination parameters:**
|
|
126
|
+
- `filter` - Filter results by string match
|
|
127
|
+
- `limit` - Maximum number of results
|
|
128
|
+
- `offset` - Skip first N results
|
|
129
|
+
- `after` - Cursor for next page
|
|
130
|
+
- `before` - Cursor for previous page
|
|
62
131
|
|
|
63
|
-
|
|
64
|
-
- Media endpoint location: `/micropub?q=media-endpoint`
|
|
65
|
-
- Available syndication targets (list): `/micropub?q=syndicate-to`
|
|
66
|
-
- Supported queries: `/micropub?q=config`
|
|
67
|
-
- Supported vocabularies (list): `/micropub?q=post-types`
|
|
68
|
-
- Publication categories (list): `/micropub?q=category`
|
|
69
|
-
- Previously published posts (list): `/micropub?q=source`
|
|
70
|
-
- Source content: `/micropub?q=source&url=WEBSITE_URL`
|
|
132
|
+
Example: `/micropub?q=source&filter=web&limit=10&offset=10`
|
|
71
133
|
|
|
72
|
-
|
|
134
|
+
## Features
|
|
135
|
+
|
|
136
|
+
### Media Uploads
|
|
137
|
+
|
|
138
|
+
Supports file uploads via multipart/form-data for `photo`, `video`, and `audio` properties. Files are uploaded to the media endpoint before post creation.
|
|
139
|
+
|
|
140
|
+
### Post Type Discovery
|
|
141
|
+
|
|
142
|
+
Implements the [Post Type Discovery](https://ptd.spec.indieweb.org/) algorithm with custom type-based detection:
|
|
143
|
+
|
|
144
|
+
1. Event type (`type: "event"`)
|
|
145
|
+
2. **Custom h type** (fork feature - matches configured post type names)
|
|
146
|
+
3. Standard discovery properties (`rsvp`, `repost-of`, `like-of`, `in-reply-to`, `video`, `photo`)
|
|
147
|
+
4. Custom discovery properties (from post type config)
|
|
148
|
+
5. Collection (populated `children` array)
|
|
149
|
+
6. Article (`name` + `content`)
|
|
150
|
+
7. Note (default fallback)
|
|
151
|
+
|
|
152
|
+
### Content Normalization
|
|
153
|
+
|
|
154
|
+
Automatically converts between Markdown and HTML:
|
|
155
|
+
- Plaintext only → generates HTML via markdown-it
|
|
156
|
+
- HTML only → generates plaintext via Turndown
|
|
157
|
+
- Markdown conversion uses typographer and smart quotes
|
|
158
|
+
|
|
159
|
+
### Soft Deletes
|
|
160
|
+
|
|
161
|
+
Deleted posts are not removed from the database. They store `_deletedProperties` for restoration via the `undelete` action.
|
|
162
|
+
|
|
163
|
+
## Requirements
|
|
164
|
+
|
|
165
|
+
This endpoint requires:
|
|
166
|
+
- MongoDB database for storing post metadata
|
|
167
|
+
- IndieAuth authentication endpoint (`@indiekit/endpoint-auth` or `@rmdes/indiekit-endpoint-auth`)
|
|
168
|
+
- Media endpoint (`@indiekit/endpoint-media`)
|
|
169
|
+
- At least one post type plugin
|
|
170
|
+
- At least one preset plugin (Jekyll, Hugo, Eleventy, etc.)
|
|
171
|
+
- At least one store plugin (GitHub, GitLab, Gitea)
|
|
172
|
+
|
|
173
|
+
## Related Plugins
|
|
174
|
+
|
|
175
|
+
### Works With
|
|
176
|
+
|
|
177
|
+
- **Post types:** `@indiekit/post-type-*`, `@rmdes/indiekit-post-type-page`
|
|
178
|
+
- **Syndicators:** `@rmdes/indiekit-syndicator-bluesky`, `@rmdes/indiekit-syndicator-mastodon`, `@rmdes/indiekit-syndicator-indienews`
|
|
179
|
+
- **Presets:** `@rmdes/indiekit-preset-eleventy`, `@indiekit/preset-jekyll`, `@indiekit/preset-hugo`
|
|
180
|
+
- **Stores:** `@indiekit/store-github`, `@indiekit/store-gitlab`, `@indiekit/store-gitea`
|
|
181
|
+
|
|
182
|
+
### Optional
|
|
183
|
+
|
|
184
|
+
- `@indiekit/endpoint-posts` or `@rmdes/indiekit-endpoint-posts` - Web UI for post management
|
|
185
|
+
- `@indiekit/endpoint-syndicate` or `@rmdes/indiekit-endpoint-syndicate` - Manual syndication UI
|
|
186
|
+
|
|
187
|
+
## Documentation
|
|
188
|
+
|
|
189
|
+
See [CLAUDE.md](./CLAUDE.md) for complete technical reference, architecture details, and integration guidance.
|
|
190
|
+
|
|
191
|
+
## Debugging
|
|
192
|
+
|
|
193
|
+
Enable debug output:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
DEBUG=indiekit:endpoint-micropub:* npm start
|
|
197
|
+
```
|
|
73
198
|
|
|
74
199
|
## License
|
|
75
200
|
|
|
76
|
-
MIT - Original work by Paul Robert Lloyd,
|
|
201
|
+
MIT - Original work by [Paul Robert Lloyd](https://paulrobertlloyd.com), custom features by [Ricardo Mendes](https://rmendes.net).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-micropub",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Micropub endpoint for Indiekit with custom type-based post discovery. Enables publishing content to your website using the Micropub protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|