( staticPageFiles: FileMap, dynamicPages: string[], entryDirectory: string, htmlContentType: string, prerenderManifest: NextPrerenderedRoutes, nextVersion: string, routesManifest?: RoutesManifest )
| 892 | type FileMap = { [page: string]: FileFsRef }; |
| 893 | |
| 894 | export function filterStaticPages( |
| 895 | staticPageFiles: FileMap, |
| 896 | dynamicPages: string[], |
| 897 | entryDirectory: string, |
| 898 | htmlContentType: string, |
| 899 | prerenderManifest: NextPrerenderedRoutes, |
| 900 | nextVersion: string, |
| 901 | routesManifest?: RoutesManifest |
| 902 | ) { |
| 903 | const staticPages: FileMap = {}; |
| 904 | |
| 905 | Object.keys(staticPageFiles).forEach((page: string) => { |
| 906 | const pathname = page.replace(/\.html$/, ''); |
| 907 | const routeName = normalizeLocalePath( |
| 908 | normalizePage(pathname), |
| 909 | routesManifest?.i18n?.locales |
| 910 | ).pathname; |
| 911 | |
| 912 | // Prerendered routes emit a `.html` file but should not be treated as a |
| 913 | // static page. |
| 914 | // Lazily prerendered routes have a fallback `.html` file on newer |
| 915 | // Next.js versions so we need to also not treat it as a static page here. |
| 916 | if ( |
| 917 | prerenderManifest.staticRoutes[routeName] || |
| 918 | prerenderManifest.fallbackRoutes[routeName] || |
| 919 | prerenderManifest.staticRoutes[normalizePage(pathname)] || |
| 920 | prerenderManifest.fallbackRoutes[normalizePage(pathname)] |
| 921 | ) { |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | const staticRoute = path.posix.join(entryDirectory, pathname); |
| 926 | |
| 927 | staticPages[staticRoute] = staticPageFiles[page]; |
| 928 | staticPages[staticRoute].contentType = htmlContentType; |
| 929 | |
| 930 | if (isDynamicRoute(pathname, nextVersion)) { |
| 931 | dynamicPages.push(routeName); |
| 932 | return; |
| 933 | } |
| 934 | }); |
| 935 | |
| 936 | return staticPages; |
| 937 | } |
| 938 | |
| 939 | export function getFilesMapFromReasons( |
| 940 | fileList: ReadonlySet<string>, |
no test coverage detected