Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Can anyone please provide a translated fullTitle field example?

default discord avatar
zephury.last 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
    clement6396last 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

  • default discord avatar
    zephury.last year

    thank you 🙂

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.