r1tsuu

better use as title

by r1tsuu
payload-enchants
Admin customization
v3
^3.0.0-beta.61
MIT

Overview

Summary generated from the README

Adds a generated title field to selected collections, computed by a function you define from the document data, request and user. The function can be asynchronous. The field name can be overridden globally or per collection. Existing documents need a manual update script to populate the title. Targets Payload 3.0 beta.

Features

  • Per-collection useAsTitle function receiving document data and request
  • Supports asynchronous title functions
  • Field overrides globally or per collection
  • Configured through the plugins array in payload.config

Use cases

  • Show a combined name and age as the document title in the admin list
  • Build titles from related data fetched through the request's payload instance

Installation

npm i @payload-enchants/better-use-as-title

335

Stars

28

Forks

28

Open Issues

1 years ago

Last Updated

117

Weekly Downloads

v1.2.2

npm Version

15.4 KB

Unpacked Size

0

Dependencies

Repository stars

335+2 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 2026335
Dec 5, 2026335
Dec 4, 2026335
Dec 3, 2026335
Dec 2, 2026335
Dec 1, 2026335
Nov 30, 2026335
Nov 29, 2026335
Nov 28, 2026335
Nov 27, 2026335
Nov 26, 2026335
Nov 25, 2026335
Nov 24, 2026335
Nov 23, 2026335
Nov 22, 2026335
Nov 21, 2026335
Nov 20, 2026335
Nov 19, 2026336
Nov 18, 2026336
Nov 17, 2026335
Nov 16, 2026335
Nov 15, 2026335
Nov 14, 2026335
Nov 13, 2026335
Nov 12, 2026335
Nov 11, 2026335
Nov 10, 2026335
Nov 9, 2026335
Nov 8, 2026335
Nov 7, 2026335
Nov 6, 2026335
Nov 5, 2026335
Nov 4, 2026335
Nov 3, 2026335
Nov 2, 2026335
Nov 1, 2026335
Oct 31, 2026335
Oct 30, 2026335
Oct 29, 2026335
Oct 28, 2026335
Oct 27, 2026335
Oct 26, 2026335
Oct 25, 2026335
Oct 24, 2026334
Oct 23, 2026334
Oct 22, 2026334
Oct 21, 2026334
Oct 20, 2026334
Oct 19, 2026334
Oct 18, 2026334
Oct 17, 2026334
Oct 16, 2026334
Oct 15, 2026334
Oct 14, 2026334
Oct 13, 2026334
Oct 12, 2026334
Oct 11, 2026333
Oct 10, 2026333
Oct 9, 2026333
Oct 8, 2026333
Oct 7, 2026333
Oct 6, 2026333
Oct 5, 2026333
Oct 4, 2026333
Oct 3, 2026333
Oct 2, 2026333
Oct 1, 2026333
Sep 30, 2026333
Sep 29, 2026333
Sep 28, 2026333
Sep 27, 2026333
Sep 26, 2026333
Sep 25, 2026333
Sep 24, 2026333
Sep 23, 2026333
Sep 22, 2026333
Sep 21, 2026333
Sep 20, 2026333
Sep 19, 2026333
Sep 18, 2026333
Sep 17, 2026333
Sep 16, 2026333
Sep 15, 2026333
Sep 14, 2026333
Sep 13, 2026333
Sep 12, 2026333
Sep 11, 2026333
Sep 10, 2026333
Sep 9, 2026333
Sep 8, 2026333
Sep 7, 2026333

Shared by 7 plugins in r1tsuu/payload-enchants.

npm weekly downloads

117−2.1K since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026117
Dec 5, 2026117
Dec 4, 202647
Dec 3, 202643
Dec 2, 20268
Dec 1, 20269
Nov 30, 20268
Nov 29, 202646
Nov 28, 202652
Nov 27, 202652
Nov 26, 202673
Nov 25, 202675
Nov 24, 202673
Nov 23, 202673
Nov 22, 202637
Nov 21, 202632
Nov 20, 202683
Nov 19, 2026119
Nov 18, 2026124
Nov 17, 2026145
Nov 16, 2026164
Nov 15, 2026174
Nov 14, 2026188
Nov 13, 2026169
Nov 12, 2026148
Nov 11, 2026197
Nov 10, 2026226
Nov 9, 2026219
Nov 8, 2026239
Nov 7, 2026230
Nov 6, 2026202
Nov 5, 2026176
Nov 4, 2026129
Nov 3, 202681
Nov 2, 202674
Nov 1, 202652
Oct 31, 202654
Oct 30, 202665
Oct 29, 202655
Oct 28, 202644
Oct 27, 202646
Oct 26, 202649
Oct 25, 202662
Oct 24, 202664
Oct 23, 202648
Oct 22, 202675
Oct 21, 202699
Oct 20, 2026101
Oct 19, 202699
Oct 18, 202688
Oct 17, 202694
Oct 16, 2026116
Oct 15, 202699
Oct 14, 2026126
Oct 13, 2026124
Oct 12, 2026121
Oct 11, 2026111
Oct 10, 202696
Oct 9, 202677
Oct 8, 202670
Oct 7, 202631
Oct 6, 202629
Oct 5, 202628
Oct 4, 202633
Oct 3, 202638
Oct 2, 202646
Oct 1, 202667
Sep 30, 202679
Sep 29, 202682
Sep 28, 202689
Sep 27, 2026182
Sep 26, 2026358
Sep 25, 2026938
Sep 24, 20261,688
Sep 23, 20261,925
Sep 22, 20262,080
Sep 21, 20262,178
Sep 20, 20267,334
Sep 19, 20269,784
Sep 18, 20269,641
Sep 17, 20269,420
Sep 16, 20269,442
Sep 15, 202610,605
Sep 14, 202611,033
Sep 13, 20265,950
Sep 12, 20263,542
Sep 11, 20263,571
Sep 10, 20263,181
Sep 9, 20263,067
Sep 8, 20262,019
Sep 7, 20262,229

Each point is npm's rolling 7-day download count.

Health Score

50/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/684372049-better-use-as-title.svg)](https://payloaddirectory.dev/plugins/684372049-better-use-as-title)
HTML
<a href="https://payloaddirectory.dev/plugins/684372049-better-use-as-title"><img src="https://payloaddirectory.dev/badge/684372049-better-use-as-title.svg" alt="Payload Directory"></a>
Updated Jan 4, 2025Created Aug 29, 2023Published Jul 16, 2024

README

Better useAsTitle property for Payload 3.0

screen-capture.webm

Install

pnpm add @payload-enchants/better-use-as-title

Add into your payload.config.ts:

import { betterUseAsTitle } from '@payload-enchants/better-use-as-title';

export default buildConfig({
  // ...your config
  plugins: [
    betterUseAsTitle({
      // List of collections to apply a custom `useAsTitle`
      collections: [
        {
          // Collection slug
          slug: 'better-use-as-title-test',

          // `data` is the current document data, req is instance of PayloadRequest, from which you can get `payload` and `user`
          // could be asynchronous as well
          useAsTitle: ({ data, req }) =>
            `${data.firstName ?? ''} - ${data.secondName}, ${data.age} y.o`,

          // override properties for useAsTitle field for this collection
          fieldOverride: {
            name: 'customNameForCollection',
          },
        },
      ],
      // override properties for useAsTitle field globally
      fieldOverride: {
        name: 'customName',
      },
    }),
  ],
});

Note for data that already exist

You would need to write a custom script that updates all your docs like this

payload.update({
  collection: 'posts',
  where: {}
})

Similar plugins