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

Code before:
          );
        }
      }

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

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

      const {addRoute, createData} = actions;

      async function createPageRouteMetadata(
        metadata: Metadata,
      ): Promise<RouteMetadata> {
        if (metadata.type === 'mdx') {
          return {
            sourceFilePath: aliasedSitePathToRelativePath(metadata.source),
            lastUpdatedAt: metadata.lastUpdatedAt,
          };
        }

        return {
          sourceFilePath: aliasedSitePathToRelativePath(metadata.source),
          lastUpdatedAt: undefined,
        };
      }

      await Promise.all(
        content.map(async (metadata) => {
          const {permalink, source} = metadata;
          const routeMetadata = await createPageRouteMetadata(metadata);
          if (metadata.type === 'mdx') {
            await createData(
              // Note that this created data path must be in sync with
              // metadataPath provided to mdx-loader.
              `${docuHash(metadata.source)}.json`,
              JSON.stringify(metadata, null, 2),
            );
            addRoute({
              path: permalink,
              component: options.mdxPageComponent,
              exact: true,
              metadata: routeMetadata,
              modules: {
                content: source,
              },

Review comment (suggestion):
I'd prefer to express it this way for future-proofness:

```tsx
const lastUpdatedAt = metadata.type === 'mdx' ? metadata.lastUpdatedAt : undefined;

return {sourceFilePath,lastUpdatedAt};
```



Code after:
            const contentPathEditUrl = normalizeUrl([
              editUrl,
              posixPath(path.relative(siteDir, fileContentPath)),
            ]);

            return getEditUrl(pagesPathRelative, contentPathEditUrl);
          }
          return undefined;
        }

        const lastUpdatedData = await readLastUpdateData(
          source,
          options,
          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[];
    },