-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate fixed route path for favicon.ico (#46997)
Generate `/favicon.ico` route when favicon.ico is placed into `app/`. Still collect favicon metadata image information through metadata-image-loader but don't emit the file to static dist anymore. Also collect favicon through metadata routes, and render it as static routes. Also remove the `hash` we generated before, not needed anymore. Change metadata static routes rendering process: collect static metadata assets, read the buffer of the file data and return it in the response. Closes NEXT-791
- Loading branch information
Showing
9 changed files
with
91 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import path from '../shared/lib/isomorphic/path' | ||
|
||
export function isAppRouteRoute(route: string): boolean { | ||
return route.endsWith('/route') | ||
} | ||
|
||
// TODO: support more metadata routes | ||
const staticMetadataRoutes = ['robots.txt', 'sitemap.xml'] | ||
// Match routes that are metadata routes, e.g. /sitemap.xml, /favicon.<ext>, /<icon>.<ext>, etc. | ||
// TODO-METADATA: support more metadata routes with more extensions | ||
const staticMetadataRoutes = ['robots.txt', 'sitemap.xml', 'favicon.ico'] | ||
export function isMetadataRoute(route: string): boolean { | ||
// Remove the 'app/' or '/' prefix, only check the route name since they're only allowed in root app directory | ||
const filename = route.replace(/^app\//, '').replace(/^\//, '') | ||
return staticMetadataRoutes.includes(filename) | ||
} | ||
|
||
// Only match the static metadata files | ||
// TODO-METADATA: support static metadata files under nested routes folders | ||
export function isStaticMetadataRoute(resourcePath: string) { | ||
const filename = path.basename(resourcePath) | ||
return staticMetadataRoutes.includes(filename) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters