@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 CHANGED
@@ -7,13 +7,13 @@ frontmatter date.
7
7
 
8
8
  ## Overview
9
9
 
10
- `recentPosts()` provides a `RecentPosts` component that renders an ordered list
11
- of recently posted articles. `getRecentPosts()` reads
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. Whether and where to place the list is the site's
16
- decision.
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
- ### Render the component
36
+ ### Custom placement
36
37
 
37
38
  ```tsx
38
- import RecentPosts, { getRecentPosts } from "@riebeckite/plugin-recent-posts";
39
- import { content } from "../content";
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 your route
44
- return <Article afterContent={<RecentPosts posts={recentPosts} />} />;
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` は結果が空なら何も描画しません。一覧を置くかどうか、どこへ置くかは Site 側で決めます。
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, { getRecentPosts } from "@riebeckite/plugin-recent-posts";
24
- import { content } from "../content";
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 <Article afterContent={<RecentPosts posts={posts} />} />;
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,6 +1,6 @@
1
1
  import type { RecentPost } from "../src/recent-posts.js";
2
2
  type Props = {
3
- posts: RecentPost[];
3
+ posts?: RecentPost[];
4
4
  };
5
5
  export default function RecentPosts(props: Props): import("hono/jsx/jsx-dev-runtime").JSX.Element;
6
6
  export {};
@@ -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
- if (props.posts.length === 0) return null;
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: props.posts.map((post) => {
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
- if (props.posts.length === 0) return null;
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: props.posts.map((post) => {
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.20",
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.20"
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: 4rem;
3
+ margin-top: var(--rb-space-6, 3rem);
4
4
  padding-top: 1.5rem;
5
- border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
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: clamp(1.5rem, 4vw, 2rem);
15
+ font-size: 1.125rem;
16
+ font-weight: 700;
15
17
  line-height: 1.2;
16
18
  letter-spacing: -0.02em;
17
19
  }