@riebeckite/plugin-seo 0.0.13 → 0.0.15
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 +5 -3
- package/README_ja.md +4 -4
- package/dist/index.js +22 -7
- package/dist/src/content.d.ts +1 -1
- package/dist/src/types.d.ts +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ export default defineConfig({
|
|
|
22
22
|
seo({
|
|
23
23
|
siteName: "Riebeckite Blog",
|
|
24
24
|
defaultImage: "/ogp.png",
|
|
25
|
-
feed: { rss: true, atom: true, json: true },
|
|
25
|
+
feed: { rss: true, atom: true, json: true, limit: 30 },
|
|
26
26
|
sitemap: true,
|
|
27
27
|
robots: true,
|
|
28
28
|
}),
|
|
@@ -36,7 +36,7 @@ export default defineConfig({
|
|
|
36
36
|
| ------ | ---- | ----------- |
|
|
37
37
|
| `siteName` | `string` | Site name used in page titles. Defaults to `site.title`. |
|
|
38
38
|
| `defaultImage` | `string` | Default OG image. Falls back to `site.defaultOgImage`. |
|
|
39
|
-
| `feed` | `{ rss?: boolean; atom?: boolean; json?: boolean }` | Feed output settings. |
|
|
39
|
+
| `feed` | `{ rss?: boolean; atom?: boolean; json?: boolean; limit?: number }` | Feed output settings. `limit` defaults to 30 and applies to every format. |
|
|
40
40
|
| `sitemap` | `boolean` | Sitemap output settings. |
|
|
41
41
|
| `robots` | `boolean` | robots.txt output settings. |
|
|
42
42
|
|
|
@@ -75,6 +75,8 @@ Feed and sitemap entries are filtered with `isPublished`, exclude
|
|
|
75
75
|
`noindex: true`, and are sorted by the most recent update first. Their URLs use
|
|
76
76
|
each entry's resolved canonical `permalink` (`ContentManifestEntry.permalink`);
|
|
77
77
|
they are never rebuilt from slugs.
|
|
78
|
+
Feeds include the latest 30 entries by default. Set `feed.limit` to change the
|
|
79
|
+
shared limit for RSS, Atom, and JSON Feed.
|
|
78
80
|
|
|
79
81
|
## Reading time
|
|
80
82
|
|
|
@@ -107,4 +109,4 @@ they are never rebuilt from slugs.
|
|
|
107
109
|
|
|
108
110
|
## See also
|
|
109
111
|
|
|
110
|
-
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
|
112
|
+
- [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -16,7 +16,7 @@ export default defineConfig({
|
|
|
16
16
|
seo({
|
|
17
17
|
siteName: "Riebeckite Blog",
|
|
18
18
|
defaultImage: "/ogp.png",
|
|
19
|
-
feed: { rss: true, atom: true, json: true },
|
|
19
|
+
feed: { rss: true, atom: true, json: true, limit: 30 },
|
|
20
20
|
sitemap: true,
|
|
21
21
|
robots: true,
|
|
22
22
|
}),
|
|
@@ -28,7 +28,7 @@ export default defineConfig({
|
|
|
28
28
|
| --- | --- |
|
|
29
29
|
| `siteName` | ページタイトルに使うサイト名。省略時は `site.title` |
|
|
30
30
|
| `defaultImage` | 既定の OGP 画像。省略時は `site.defaultOgImage` |
|
|
31
|
-
| `feed` | RSS、Atom、JSON Feed
|
|
31
|
+
| `feed` | RSS、Atom、JSON Feed の出力を個別に有効化する。`limit` は全形式共通の件数上限で、既定値は 30 件 |
|
|
32
32
|
| `sitemap` | サイトマップを出力する |
|
|
33
33
|
| `robots` | robots.txt を出力する |
|
|
34
34
|
|
|
@@ -51,7 +51,7 @@ export default defineConfig({
|
|
|
51
51
|
|
|
52
52
|
## 公開物に含まれる記事
|
|
53
53
|
|
|
54
|
-
サイトマップとフィードは、公開済みで `noindex: true`
|
|
54
|
+
サイトマップとフィードは、公開済みで `noindex: true` ではないエントリーだけを対象にし、更新日時の新しい順に並べます。フィードは既定で最新 30 件を含み、`feed.limit` で RSS・Atom・JSON Feed 共通の件数上限を変更できます。URL には各エントリーの解決済み canonical `permalink`(`ContentManifestEntry.permalink`)を使い、slug から再構築しません。出力関数は `renderSitemap`、`renderRobots`、`renderRssFeed`、`renderAtomFeed`、`renderJsonFeed` です。
|
|
55
55
|
|
|
56
56
|
読了時間は CJK 文字を毎分 500 文字、ラテン文字の単語を毎分 220 語として数え、最低 1 分に切り上げます。
|
|
57
57
|
|
|
@@ -65,4 +65,4 @@ export default defineConfig({
|
|
|
65
65
|
|
|
66
66
|
## 関連資料
|
|
67
67
|
|
|
68
|
-
- [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
|
|
68
|
+
- [プラグインシステム](../../../docs/ja/docs/reference/plugin-api.md)
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/content.ts
|
|
2
|
-
import {
|
|
2
|
+
import { stripHtml } from "@riebeckite/core";
|
|
3
3
|
function getDescription(post) {
|
|
4
4
|
const frontmatterDescription = post.frontmatter.description;
|
|
5
5
|
if (typeof frontmatterDescription === "string" && frontmatterDescription.trim()) {
|
|
@@ -7,8 +7,8 @@ function getDescription(post) {
|
|
|
7
7
|
}
|
|
8
8
|
return stripHtml(post.html).replace(/\s+/g, " ").trim().slice(0, 160);
|
|
9
9
|
}
|
|
10
|
-
function filterFeedEntries(
|
|
11
|
-
return entries.filter((entry) =>
|
|
10
|
+
function filterFeedEntries(_config, entries, limit = 30) {
|
|
11
|
+
return entries.filter((entry) => entry.frontmatter.noindex !== true).sort((a, b) => getSortableTime(b) - getSortableTime(a)).slice(0, Math.max(0, Math.floor(limit)));
|
|
12
12
|
}
|
|
13
13
|
function getEntryPublishedTime(entry) {
|
|
14
14
|
return getIsoDate(
|
|
@@ -282,7 +282,7 @@ function createSeoEndpoints(options) {
|
|
|
282
282
|
path: "/sitemap.xml",
|
|
283
283
|
handler: ({ config, manifest }) => ({
|
|
284
284
|
headers: { "content-type": "application/xml; charset=utf-8" },
|
|
285
|
-
body: renderSitemap(config, manifest.
|
|
285
|
+
body: renderSitemap(config, manifest.discoverableEntries)
|
|
286
286
|
})
|
|
287
287
|
});
|
|
288
288
|
}
|
|
@@ -302,7 +302,11 @@ function createSeoEndpoints(options) {
|
|
|
302
302
|
headers: { "content-type": "application/rss+xml; charset=utf-8" },
|
|
303
303
|
body: renderRssFeed(
|
|
304
304
|
config,
|
|
305
|
-
filterFeedEntries(
|
|
305
|
+
filterFeedEntries(
|
|
306
|
+
config,
|
|
307
|
+
manifest.discoverableEntries,
|
|
308
|
+
options.feed?.limit
|
|
309
|
+
)
|
|
306
310
|
)
|
|
307
311
|
})
|
|
308
312
|
});
|
|
@@ -314,7 +318,11 @@ function createSeoEndpoints(options) {
|
|
|
314
318
|
headers: { "content-type": "application/atom+xml; charset=utf-8" },
|
|
315
319
|
body: renderAtomFeed(
|
|
316
320
|
config,
|
|
317
|
-
filterFeedEntries(
|
|
321
|
+
filterFeedEntries(
|
|
322
|
+
config,
|
|
323
|
+
manifest.discoverableEntries,
|
|
324
|
+
options.feed?.limit
|
|
325
|
+
)
|
|
318
326
|
)
|
|
319
327
|
})
|
|
320
328
|
});
|
|
@@ -324,7 +332,14 @@ function createSeoEndpoints(options) {
|
|
|
324
332
|
path: "/feed.json",
|
|
325
333
|
handler: ({ config, manifest }) => ({
|
|
326
334
|
json: JSON.parse(
|
|
327
|
-
renderJsonFeed(
|
|
335
|
+
renderJsonFeed(
|
|
336
|
+
config,
|
|
337
|
+
filterFeedEntries(
|
|
338
|
+
config,
|
|
339
|
+
manifest.discoverableEntries,
|
|
340
|
+
options.feed?.limit
|
|
341
|
+
)
|
|
342
|
+
)
|
|
328
343
|
)
|
|
329
344
|
})
|
|
330
345
|
});
|
package/dist/src/content.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContentManifestEntry, PostContent, ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
2
|
export declare function getDescription(post: Pick<PostContent, "frontmatter" | "html">): string;
|
|
3
|
-
export declare function filterFeedEntries(
|
|
3
|
+
export declare function filterFeedEntries(_config: ResolvedRiebeckiteConfig, entries: ContentManifestEntry[], limit?: number): ContentManifestEntry[];
|
|
4
4
|
export declare function getEntryPublishedTime(entry: ContentManifestEntry): string | null;
|
|
5
5
|
export declare function getEntryUpdatedTime(entry: ContentManifestEntry): string | null;
|
|
6
6
|
export declare function getHtmlLanguage(config: ResolvedRiebeckiteConfig): string;
|
package/dist/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-seo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@riebeckite/core": "0.0.
|
|
17
|
+
"@riebeckite/core": "0.0.15"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsx": "^4.22.4",
|
|
21
|
-
"@riebeckite/test": "0.0.
|
|
21
|
+
"@riebeckite/test": "0.0.15"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|