Can anyone please provide a translated fullTitle field example?

default discord avatar
Zephurylast year
2

Commonly, you see "fullTitle" fields, like this, for supporting readable names on nested documents:


import type { FieldHook } from "payload/types";

export const generateFullTitle = (breadcrumbs: unknown): string | undefined => {
    if (Array.isArray(breadcrumbs)) {
        console.log(breadcrumbs);
        return breadcrumbs.reduce((title, breadcrumb, i) => {
            if (i === 0) return `${breadcrumb.label}`;
            return `${title} > ${breadcrumb.label}`;
        }, "");
    }

    return undefined;
};

const populateFullTitle: FieldHook = async ({ data, originalDoc }) =>
    generateFullTitle(data?.breadcrumbs || originalDoc?.breadcrumbs);

export default populateFullTitle;


however, it will always be overriden by whichever language last edited it, rather than maintaining a full title for each user language.



I'd really appreciate an example of how to solve this sort of thing

  • default discord avatar
    <Clement/>last year

    Hello, I can show you mine, if you want, it works well with multi locales





    I named it _breadcrumb, not fullTitle but that's the same





    I use nested doc official plugin to get the

    breadcrumbs

    array

    image.png
    image.png
  • default discord avatar
    Zephurylast year

    thank you 🙂

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.