New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

[screen-capture.webm](https://github.com/r1tsuu/payload-enchants/assets/64744993/ba3a8e37-3f5e-48a4-ac25-9ea81bc43b01)

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
decreased by-33.96%
Maintainers
0
Weekly downloads
 
Created
Source

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: {}
})

FAQs

Package last updated on 16 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc