File tree Expand file tree Collapse file tree 3 files changed +56
-44
lines changed
license/[licenseType]/[licenseId] Expand file tree Collapse file tree 3 files changed +56
-44
lines changed Original file line number Diff line number Diff line change @@ -32,25 +32,29 @@ const getCachedNodeOperatorProfile = unstable_cache(
3232
3333export async function generateMetadata ( { params } ) {
3434 const { ownerEthAddr } = await params ;
35- const canonical = `/account/${ encodeURIComponent ( ownerEthAddr ) } ` ;
3635 const errorMetadata = {
3736 title : 'Error' ,
3837 openGraph : {
3938 title : 'Error' ,
4039 } ,
41- alternates : {
42- canonical,
43- } ,
4440 } ;
4541
4642 if ( ! ownerEthAddr || ! isAddress ( ownerEthAddr ) || isZeroAddress ( ownerEthAddr ) ) {
4743 return errorMetadata ;
4844 }
49-
50- try {
51- const [ ensName , publicProfile ] = await Promise . all ( [
52- cachedGetENSName ( ownerEthAddr ) ,
53- getCachedNodeOperatorProfile ( ownerEthAddr as types . EthAddress ) ,
45+
46+ const canonical = `/account/${ encodeURIComponent ( ownerEthAddr ) } ` ;
47+ const errorMetadataWithCanonical = {
48+ ...errorMetadata ,
49+ alternates : {
50+ canonical,
51+ } ,
52+ } ;
53+
54+ try {
55+ const [ ensName , publicProfile ] = await Promise . all ( [
56+ cachedGetENSName ( ownerEthAddr ) ,
57+ getCachedNodeOperatorProfile ( ownerEthAddr as types . EthAddress ) ,
5458 ] ) ;
5559
5660 const primaryName = publicProfile ?. name || ensName || getShortAddress ( ownerEthAddr , 4 , true ) ;
@@ -65,7 +69,7 @@ export async function generateMetadata({ params }) {
6569 } ,
6670 } ;
6771 } catch ( error ) {
68- return errorMetadata ;
72+ return errorMetadataWithCanonical ;
6973 }
7074}
7175
Original file line number Diff line number Diff line change @@ -12,33 +12,37 @@ import { cache, Suspense } from 'react';
1212
1313export async function generateMetadata ( { params } ) {
1414 const { licenseType, licenseId } = await params ;
15- const canonical = `/license/${ encodeURIComponent ( licenseType ) } /${ encodeURIComponent ( licenseId ) } ` ;
1615 const errorMetadata = {
1716 title : 'Error' ,
1817 openGraph : {
1918 title : 'Error' ,
2019 } ,
21- alternates : {
22- canonical,
23- } ,
2420 } ;
25-
26- if ( ! licenseType || ! [ 'ND' , 'MND' , 'GND' ] . includes ( licenseType ) ) {
27- return errorMetadata ;
28- }
21+
22+ if ( ! licenseType || ! [ 'ND' , 'MND' , 'GND' ] . includes ( licenseType ) ) {
23+ return errorMetadata ;
24+ }
2925
3026 const licenseIdNum = parseInt ( licenseId ) ;
3127
32- if ( isNaN ( licenseIdNum ) || licenseIdNum < 0 || licenseIdNum > 10000 ) {
33- return errorMetadata ;
34- }
35-
36- try {
37- await fetchLicense ( licenseType , licenseId , config . environment ) ;
38- } catch ( error ) {
39- return errorMetadata ;
40- }
41-
28+ if ( isNaN ( licenseIdNum ) || licenseIdNum < 0 || licenseIdNum > 10000 ) {
29+ return errorMetadata ;
30+ }
31+
32+ const canonical = `/license/${ encodeURIComponent ( licenseType ) } /${ encodeURIComponent ( licenseId ) } ` ;
33+ const errorMetadataWithCanonical = {
34+ ...errorMetadata ,
35+ alternates : {
36+ canonical,
37+ } ,
38+ } ;
39+
40+ try {
41+ await fetchLicense ( licenseType , licenseId , config . environment ) ;
42+ } catch ( error ) {
43+ return errorMetadataWithCanonical ;
44+ }
45+
4246 return {
4347 title : `License #${ licenseId } ` ,
4448 openGraph : {
Original file line number Diff line number Diff line change @@ -34,32 +34,36 @@ const resolveNodeEthAddress = (nodeAddress?: string): types.EthAddress | null =>
3434
3535export async function generateMetadata ( { params } ) {
3636 const { nodeAddr } = await params ;
37- const canonical = `/node/${ encodeURIComponent ( nodeAddr ) } ` ;
3837 const errorMetadata = {
3938 title : 'Error' ,
4039 openGraph : {
4140 title : 'Error' ,
4241 } ,
43- alternates : {
44- canonical,
45- } ,
4642 } ;
4743 const resolvedNodeEthAddr = resolveNodeEthAddress ( nodeAddr ) ;
4844
4945 if ( ! resolvedNodeEthAddr ) {
5046 console . log ( `[Node Page] Invalid node address: ${ nodeAddr } ` ) ;
51- return errorMetadata ;
52- }
53-
54- let nodeResponse : types . OraclesAvailabilityResult & types . OraclesDefaultResult ;
55-
56- try {
57- ( { nodeResponse } = await fetchLicenseDetailsAndNodeAvailability ( resolvedNodeEthAddr , config . environment ) ) ;
58- } catch ( error ) {
59- console . error ( error ) ;
60- return errorMetadata ;
61- }
62-
47+ return errorMetadata ;
48+ }
49+
50+ const canonical = `/node/${ encodeURIComponent ( nodeAddr ) } ` ;
51+ const errorMetadataWithCanonical = {
52+ ...errorMetadata ,
53+ alternates : {
54+ canonical,
55+ } ,
56+ } ;
57+
58+ let nodeResponse : types . OraclesAvailabilityResult & types . OraclesDefaultResult ;
59+
60+ try {
61+ ( { nodeResponse } = await fetchLicenseDetailsAndNodeAvailability ( resolvedNodeEthAddr , config . environment ) ) ;
62+ } catch ( error ) {
63+ console . error ( error ) ;
64+ return errorMetadataWithCanonical ;
65+ }
66+
6367 return {
6468 title : `Node • ${ nodeResponse . node_alias } ` ,
6569 openGraph : {
You can’t perform that action at this time.
0 commit comments