Repository: facebook/docusaurus
File: packages/docusaurus-plugin-content-pages/src/index.ts (TypeScript)

Code before:
        );

        if (isDraft({frontMatter})) {
          return undefined;
        }
        const unlisted = isUnlisted({frontMatter});

        return {
          type: 'mdx',
          permalink,
          source: aliasedSourcePath,
          title: frontMatter.title ?? contentTitle,
          description: frontMatter.description ?? excerpt,
          frontMatter,
          lastUpdatedBy: lastUpdatedData.lastUpdatedBy,
          lastUpdatedAt: lastUpdatedData.lastUpdatedAt,
          editUrl: getItemEditUrl({
            editUrl,
            itemDirPath: pagesDirPath,
            itemSourceAbsolute: pagesSourceAbsolute,
            permalink,
            i18n,
            options,
            siteDir,
            contentPaths,
          }),
          unlisted,
        };
      }

      async function doProcessPageSourceFile(relativeSource: string) {
        try {
          return await processPageSourceFile(relativeSource);
        } catch (err) {
          throw new Error(
            `Processing of page source file path=${relativeSource} failed.`,
            {cause: err as Error},
          );
        }
      }

      return (
        await Promise.all(pagesFiles.map(doProcessPageSourceFile))
      ).filter(Boolean) as Metadata[];
    },

    async contentLoaded({content, actions}) {
      if (!content) {
        return;
      }


Review comment (refactor):
😄 maybe that was a bad idea, if we can only use it on the pages plugin and not all other plugins it's probably not worth it to extract to docusaurus utils 😅  (didn't see at first that the edit URL fn all have different param names)


Code after:
          frontMatter.last_update,
        );

        if (isDraft({frontMatter})) {
          return undefined;
        }
        const unlisted = isUnlisted({frontMatter});

        return {
          type: 'mdx',
          permalink,
          source: aliasedSourcePath,
          title: frontMatter.title ?? contentTitle,
          description: frontMatter.description ?? excerpt,
          frontMatter,
          lastUpdatedBy: lastUpdatedData.lastUpdatedBy,
          lastUpdatedAt: lastUpdatedData.lastUpdatedAt,
          editUrl: getPagesEditUrl(),
          unlisted,
        };
      }

      async function doProcessPageSourceFile(relativeSource: string) {
        try {
          return await processPageSourceFile(relativeSource);
        } catch (err) {
          throw new Error(
            `Processing of page source file path=${relativeSource} failed.`,
            {cause: err as Error},
          );
        }
      }

      return (
        await Promise.all(pagesFiles.map(doProcessPageSourceFile))
      ).filter(Boolean) as Metadata[];
    },

    async contentLoaded({content, actions}) {
      if (!content) {
        return;
      }

      const {addRoute, createData} = actions;

      function createPageRouteMetadata(metadata: Metadata): RouteMetadata {
        const lastUpdatedAt =
          metadata.type === 'mdx' ? metadata.lastUpdatedAt : undefined;

        return {
          sourceFilePath: aliasedSitePathToRelativePath(metadata.source),