feat(SW-200): refactoring SEO metadata handling and added functionality for static pages
This commit is contained in:
@@ -11,7 +11,6 @@ import {
|
||||
shortcutsSchema,
|
||||
} from "../schemas/blocks/shortcuts"
|
||||
import { textContentSchema } from "../schemas/blocks/textContent"
|
||||
import { page } from "../schemas/metadata"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
|
||||
import { AccountPageEnum } from "@/types/enums/accountPage"
|
||||
@@ -81,7 +80,3 @@ export const accountPageRefsSchema = z.object({
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
|
||||
export const accountPageMetadataSchema = z.object({
|
||||
account_page: page,
|
||||
})
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
GetAccountPage,
|
||||
GetAccountPageRefs,
|
||||
} from "@/lib/graphql/Query/AccountPage/AccountPage.graphql"
|
||||
import { GetMyPagesMetaData } from "@/lib/graphql/Query/AccountPage/MetaData.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
import { contentstackExtendedProcedureUID, router } from "@/server/trpc"
|
||||
@@ -16,13 +15,7 @@ import {
|
||||
generateTagsFromSystem,
|
||||
} from "@/utils/generateTag"
|
||||
|
||||
import { removeEmptyObjects } from "../../utils"
|
||||
import { getMetaData, getResponse } from "../metadata/utils"
|
||||
import {
|
||||
accountPageMetadataSchema,
|
||||
accountPageRefsSchema,
|
||||
accountPageSchema,
|
||||
} from "./output"
|
||||
import { accountPageRefsSchema, accountPageSchema } from "./output"
|
||||
import { getConnections } from "./utils"
|
||||
|
||||
import {
|
||||
@@ -30,7 +23,6 @@ import {
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import type {
|
||||
GetAccountpageMetadata,
|
||||
GetAccountPageRefsSchema,
|
||||
GetAccountPageSchema,
|
||||
} from "@/types/trpc/routers/contentstack/accountPage"
|
||||
@@ -203,30 +195,4 @@ export const accountPageQueryRouter = router({
|
||||
tracking,
|
||||
}
|
||||
}),
|
||||
metadata: router({
|
||||
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||
const variables = {
|
||||
locale: ctx.lang,
|
||||
uid: ctx.uid,
|
||||
}
|
||||
const response = await getResponse<GetAccountpageMetadata>(
|
||||
GetMyPagesMetaData,
|
||||
variables
|
||||
)
|
||||
|
||||
const validatedMetadata = accountPageMetadataSchema.safeParse(
|
||||
response.data
|
||||
)
|
||||
|
||||
if (!validatedMetadata.success) {
|
||||
console.error(
|
||||
`Failed to validate My Page MetaData Data - (uid: ${variables.uid})`
|
||||
)
|
||||
console.error(validatedMetadata.error)
|
||||
return null
|
||||
}
|
||||
|
||||
return getMetaData(validatedMetadata.data.account_page)
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user