File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { unstable_cache } from 'next/cache' ;
12import { cache } from 'react' ;
23
34import { client } from '~/client' ;
@@ -45,20 +46,26 @@ const VanityUrlQuery = graphql(`
4546 }
4647` ) ;
4748
48- const getVanityUrl = cache ( async ( ) => {
49- const { data } = await client . fetch ( {
50- document : VanityUrlQuery ,
51- fetchOptions : { next : { revalidate } } ,
52- } ) ;
49+ const getCachedVanityUrl = unstable_cache (
50+ async ( ) => {
51+ const { data } = await client . fetch ( {
52+ document : VanityUrlQuery ,
53+ fetchOptions : { next : { revalidate } } ,
54+ } ) ;
5355
54- const vanityUrl = data . site . settings ?. url . vanityUrl ;
56+ const vanityUrl = data . site . settings ?. url . vanityUrl ;
5557
56- if ( ! vanityUrl ) {
57- throw new Error ( 'Vanity URL not found in site settings' ) ;
58- }
58+ if ( ! vanityUrl ) {
59+ throw new Error ( 'Vanity URL not found in site settings' ) ;
60+ }
61+
62+ return vanityUrl ;
63+ } ,
64+ [ 'get-vanity-url' ] ,
65+ { revalidate } ,
66+ ) ;
5967
60- return vanityUrl ;
61- } ) ;
68+ const getVanityUrl = cache ( getCachedVanityUrl ) ;
6269
6370export async function getMetadataAlternates ( options : CanonicalUrlOptions ) {
6471 const { path, locale, includeAlternates = true } = options ;
You can’t perform that action at this time.
0 commit comments