@riebeckite/plugin-recent-posts 0.0.20 → 0.0.21
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 +14 -10
- package/README_ja.md +7 -6
- package/dist/components/recent-posts.d.ts +1 -1
- package/dist/components/recent-posts.js +3 -2
- package/dist/index.js +3 -2
- package/package.json +2 -2
- package/style.css +5 -3
package/README.md
CHANGED
|
@@ -7,13 +7,13 @@ frontmatter date.
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
`
|
|
11
|
-
|
|
10
|
+
`RecentPosts` renders an ordered list of recently posted articles.
|
|
11
|
+
`getRecentPosts()` reads
|
|
12
12
|
`manifest.discoverableEntries`, so `unlisted`, `draft`, and scheduled notes are
|
|
13
13
|
excluded. It derives a date from the frontmatter (`date` falling back to
|
|
14
14
|
`created`), sorts newest first, and truncates to `limit` items. Notes without a
|
|
15
|
-
parseable date are dropped.
|
|
16
|
-
|
|
15
|
+
parseable date are dropped. Official `starter` and `showcase` sites place the
|
|
16
|
+
list explicitly in their homepage route after the page content.
|
|
17
17
|
|
|
18
18
|
With no posts, the component renders nothing.
|
|
19
19
|
|
|
@@ -30,21 +30,25 @@ export default defineConfig({
|
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
`recentPostsPlugin()` registers the plugin in the plugin list and bundles
|
|
33
|
-
`style.css` into the app stylesheet.
|
|
33
|
+
`style.css` into the app stylesheet; it never renders UI itself. The generated
|
|
34
|
+
`starter` and `showcase` demonstrate the recommended homepage placement.
|
|
34
35
|
|
|
35
|
-
###
|
|
36
|
+
### Custom placement
|
|
36
37
|
|
|
37
38
|
```tsx
|
|
38
|
-
import RecentPosts,
|
|
39
|
-
import { content } from "
|
|
39
|
+
import { RecentPosts, getRecentPosts } from "@riebeckite/plugin-recent-posts";
|
|
40
|
+
import { content } from "virtual:riebeckite/content";
|
|
40
41
|
|
|
41
42
|
const recentPosts = getRecentPosts({ manifest: await content.getManifest() });
|
|
42
43
|
|
|
43
|
-
// ...in
|
|
44
|
-
return <
|
|
44
|
+
// ...in a homepage route or site-owned layout
|
|
45
|
+
return <RecentPosts posts={recentPosts} />;
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
`getRecentPosts()` filters out the `index` note before collecting posts.
|
|
49
|
+
To disable the generated homepage list, remove its `RecentPosts` import and
|
|
50
|
+
`afterContent` prop. To reposition it, move that same element to the desired
|
|
51
|
+
existing route or layout slot.
|
|
48
52
|
|
|
49
53
|
## Component
|
|
50
54
|
|
package/README_ja.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## できること
|
|
8
8
|
|
|
9
|
-
`getRecentPosts()` は `manifest.discoverableEntries` を読み、unlisted・draft・予約公開のノートと `index` ノートを除き、`frontmatter.date`、なければ `created` を基準に新しい順へ並べます。日付を解釈できないノートは一覧から外れます。`RecentPosts`
|
|
9
|
+
`getRecentPosts()` は `manifest.discoverableEntries` を読み、unlisted・draft・予約公開のノートと `index` ノートを除き、`frontmatter.date`、なければ `created` を基準に新しい順へ並べます。日付を解釈できないノートは一覧から外れます。`RecentPosts` は結果が空なら何も描画しません。公式の `starter` と `showcase` は、ホームページ route で一覧を本文の後に明示的に配置します。
|
|
10
10
|
|
|
11
11
|
## 設定と配置
|
|
12
12
|
|
|
@@ -17,16 +17,18 @@ import { recentPostsPlugin } from "@riebeckite/plugin-recent-posts";
|
|
|
17
17
|
export default defineConfig({ plugins: [recentPostsPlugin()] });
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
`recentPostsPlugin()` は UI を自動描画しません。生成された `starter` と `showcase` は推奨するホームページ配置を実装しています。独自の配置では、アプリ側で表示位置を決めます。
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
|
-
import RecentPosts,
|
|
24
|
-
import { content } from "
|
|
23
|
+
import { RecentPosts, getRecentPosts } from "@riebeckite/plugin-recent-posts";
|
|
24
|
+
import { content } from "virtual:riebeckite/content";
|
|
25
25
|
|
|
26
26
|
const posts = getRecentPosts({ manifest: await content.getManifest() });
|
|
27
|
-
return <
|
|
27
|
+
return <RecentPosts posts={posts} />;
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
生成されたホームページの一覧を無効にするには、`RecentPosts` の import と `afterContent` prop を削除します。位置を変える場合は、同じ要素を既存の route または layout の目的の slot へ移動します。
|
|
31
|
+
|
|
30
32
|
| オプション | 既定値 | 内容 |
|
|
31
33
|
| --- | --- | --- |
|
|
32
34
|
| `manifest` | 必須 | 候補ノートの取得元(`discoverableEntries`) |
|
|
@@ -42,4 +44,3 @@ return <Article afterContent={<RecentPosts posts={posts} />} />;
|
|
|
42
44
|
## 関連資料
|
|
43
45
|
|
|
44
46
|
- [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
|
|
45
|
-
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// components/recent-posts.tsx
|
|
2
2
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
3
3
|
function RecentPosts(props) {
|
|
4
|
-
|
|
4
|
+
const posts = props.posts ?? [];
|
|
5
|
+
if (posts.length === 0) return null;
|
|
5
6
|
return /* @__PURE__ */ jsxs("section", { class: "rr-recent-posts", "aria-labelledby": "recent-posts-title", children: [
|
|
6
7
|
/* @__PURE__ */ jsx("div", { class: "rr-recent-posts__header", children: /* @__PURE__ */ jsx("h2", { class: "rr-recent-posts__title", id: "recent-posts-title", children: "Recent Posts" }) }),
|
|
7
|
-
/* @__PURE__ */ jsx("ol", { class: "rr-recent-posts__list", children:
|
|
8
|
+
/* @__PURE__ */ jsx("ol", { class: "rr-recent-posts__list", children: posts.map((post) => {
|
|
8
9
|
const formattedDate = formatPostedDate(post.postedAt);
|
|
9
10
|
return /* @__PURE__ */ jsx("li", { class: "rr-recent-posts__item", children: /* @__PURE__ */ jsxs("a", { class: "rr-recent-posts__link", href: post.permalink, children: [
|
|
10
11
|
/* @__PURE__ */ jsx(
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,11 @@ import { definePlugin } from "@riebeckite/core";
|
|
|
4
4
|
// components/recent-posts.tsx
|
|
5
5
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
6
6
|
function RecentPosts(props) {
|
|
7
|
-
|
|
7
|
+
const posts = props.posts ?? [];
|
|
8
|
+
if (posts.length === 0) return null;
|
|
8
9
|
return /* @__PURE__ */ jsxs("section", { class: "rr-recent-posts", "aria-labelledby": "recent-posts-title", children: [
|
|
9
10
|
/* @__PURE__ */ jsx("div", { class: "rr-recent-posts__header", children: /* @__PURE__ */ jsx("h2", { class: "rr-recent-posts__title", id: "recent-posts-title", children: "Recent Posts" }) }),
|
|
10
|
-
/* @__PURE__ */ jsx("ol", { class: "rr-recent-posts__list", children:
|
|
11
|
+
/* @__PURE__ */ jsx("ol", { class: "rr-recent-posts__list", children: posts.map((post) => {
|
|
11
12
|
const formattedDate = formatPostedDate(post.postedAt);
|
|
12
13
|
return /* @__PURE__ */ jsx("li", { class: "rr-recent-posts__item", children: /* @__PURE__ */ jsxs("a", { class: "rr-recent-posts__link", href: post.permalink, children: [
|
|
13
14
|
/* @__PURE__ */ jsx(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-recent-posts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"hono": "^4.12.25",
|
|
25
|
-
"@riebeckite/core": "0.0.
|
|
25
|
+
"@riebeckite/core": "0.0.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsx": "^4.22.4"
|
package/style.css
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
@layer components {
|
|
2
2
|
.rr-recent-posts {
|
|
3
|
-
margin-top:
|
|
3
|
+
margin-top: var(--rb-space-6, 3rem);
|
|
4
4
|
padding-top: 1.5rem;
|
|
5
|
-
border-top: 1px solid
|
|
5
|
+
border-top: 1px solid
|
|
6
|
+
var(--rb-color-border, color-mix(in srgb, currentColor 18%, transparent));
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
.rr-recent-posts__header {
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
|
|
12
13
|
.rr-recent-posts__title {
|
|
13
14
|
margin: 0;
|
|
14
|
-
font-size:
|
|
15
|
+
font-size: 1.125rem;
|
|
16
|
+
font-weight: 700;
|
|
15
17
|
line-height: 1.2;
|
|
16
18
|
letter-spacing: -0.02em;
|
|
17
19
|
}
|