> For AI agents: the complete documentation index is available at https://docs.halo.run/llms.txt, the full documentation bundle is available at https://docs.halo.run/llms-full.txt.

# 文章数据列表显示字段

此扩展点用于扩展文章数据列表的显示字段。

![文章数据列表显示字段](/img/developer-guide/plugin/extension-points/ui/post-list-item-field-create.png)

## 定义方式

```ts
export default definePlugin({
  extensionPoints: {
    "post:list-item:field:create": (
      post: Ref<ListedPost>,
    ): EntityFieldItem[] => {
      return [
        {
          priority: 0,
          position: "start",
          component: markRaw(FooComponent),
          props: {},
          permissions: [],
          hidden: false,
        },
      ];
    },
  },
});
```

```ts title="EntityFieldItem"
export interface EntityFieldItem {
  priority: number;
  position: "start" | "end";
  component: Raw<Component>;
  props?: Record\<string, unknown\>;
  permissions?: string[];
  hidden?: boolean;
}
```

## 示例

此示例将添加一个显示文章 slug（别名）的字段。

```ts
import { definePlugin } from "@halo-dev/ui-shared";
import { markRaw, type Ref } from "vue";
import type { ListedPost } from "@halo-dev/api-client";
import { VEntityField } from "@halo-dev/components";

export default definePlugin({
  extensionPoints: {
    "post:list-item:field:create": (post: Ref<ListedPost>) => {
      return [
        {
          priority: 0,
          position: "end",
          component: markRaw(VEntityField),
          props: {
            description: post.value.post.spec.slug,
          },
          permissions: [],
          hidden: false,
        },
      ];
    },
  },
});
```

## 类型定义

### ListedPost

`ListedPost` 由 `@halo-dev/api-client` 提供，请直接使用当前依赖中的生成类型。它包含：

- `post`：文章资源。
- `categories` 和 `tags`：解析后的分类与标签。
- `owner` 和 `contributors`：作者与贡献者。
- `stats`：访问、评论等统计数据。
