diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index aaef79a..98394f1 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -14,19 +14,30 @@ import { headers } from 'next/headers'; import { userAgent } from 'next/server'; import { PropsWithChildren } from 'react'; import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter'; +import { getClient } from '@/graphql/clients/serverSideClient'; +import { GET_GENERAL_SETTINGS } from '@/graphql/queries/general'; +import { GetGeneralSettingsQuery } from '@/graphql/types/graphql'; export type LocaleLayoutParams = { params: { locale: Locale } }; -type LocaleLayoutProperties = PropsWithChildren; -export const metadata: Metadata = { - title: 'NextJs Woo', - description: 'NextJs Woo', -}; +export async function generateMetadata(): Promise { + const { data } = await getClient().query({ + query: GET_GENERAL_SETTINGS, + }); + + return { + title: { + template: `%s | ${data.generalSettings?.title!}`, + default: data.generalSettings?.title!, + }, + description: data.generalSettings?.description!, + }; +} export default async function LocaleLayout({ children, params: { locale }, -}: PropsWithChildren) { +}: PropsWithChildren) { const reqUserAgent = userAgent({ headers: headers() }); const themes: Record = { diff --git a/src/graphql/queries/general.ts b/src/graphql/queries/general.ts new file mode 100644 index 0000000..5d04d99 --- /dev/null +++ b/src/graphql/queries/general.ts @@ -0,0 +1,12 @@ +import { gql } from '@apollo/client'; + +export const GET_GENERAL_SETTINGS = gql` + query GetGeneralSettings { + generalSettings { + title + description + timezone + language + } + } +`; diff --git a/src/graphql/types/gql.ts b/src/graphql/types/gql.ts index 0e8e871..0773987 100644 --- a/src/graphql/types/gql.ts +++ b/src/graphql/types/gql.ts @@ -15,7 +15,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ const documents = { "\n query Categories {\n productCategories {\n nodes {\n id: databaseId\n name\n parentId: parentDatabaseId\n }\n }\n }\n": types.CategoriesDocument, "\n query GetMainCategories {\n productCategories(where: { parent: null, orderby: TERM_ORDER }) {\n edges {\n node {\n id: databaseId\n name\n image {\n id: databaseId\n sourceUrl\n }\n }\n }\n }\n }\n": types.GetMainCategoriesDocument, - "\n query GetPage($slug: String) {\n pages(where: { name: $slug }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n": types.GetPageDocument, + "\n query GetGeneralSettings {\n generalSettings {\n title\n description\n timezone\n language\n }\n }\n": types.GetGeneralSettingsDocument, + "\n query GetPage($slug: String) {\n pages(where: { name: $slug, status: PUBLISH }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n": types.GetPageDocument, "\n query GetAllProducts(\n $stockStatus: [StockStatusEnum]\n $orderBy: [ProductsOrderbyInput]\n $categoryIdIn: [Int]\n $q: String\n $first: Int\n ) {\n products(\n first: $first\n where: {\n stockStatus: $stockStatus\n orderby: $orderBy\n categoryIdIn: $categoryIdIn\n search: $q\n }\n ) {\n pageInfo {\n total\n hasNextPage\n hasPreviousPage\n }\n nodes {\n __typename\n ... on VariableProduct {\n databaseId\n name\n onSale\n type\n averageRating\n slug\n image {\n sourceUrl\n }\n price\n regularPrice\n salePrice\n stockStatus\n }\n }\n }\n }\n": types.GetAllProductsDocument, "\n query GetHomePageSliders {\n sliderCategories(where: { slug: \"homepage\" }) {\n nodes {\n sliders {\n edges {\n node {\n id: databaseId\n title\n url\n featuredImage {\n node {\n id: databaseId\n url: sourceUrl\n }\n }\n }\n }\n }\n }\n }\n }\n": types.GetHomePageSlidersDocument, }; @@ -45,7 +46,11 @@ export function graphql(source: "\n query GetMainCategories {\n productCateg /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query GetPage($slug: String) {\n pages(where: { name: $slug }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n"): (typeof documents)["\n query GetPage($slug: String) {\n pages(where: { name: $slug }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query GetGeneralSettings {\n generalSettings {\n title\n description\n timezone\n language\n }\n }\n"): (typeof documents)["\n query GetGeneralSettings {\n generalSettings {\n title\n description\n timezone\n language\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query GetPage($slug: String) {\n pages(where: { name: $slug, status: PUBLISH }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n"): (typeof documents)["\n query GetPage($slug: String) {\n pages(where: { name: $slug, status: PUBLISH }) {\n edges {\n node {\n title\n content\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/src/graphql/types/graphql.ts b/src/graphql/types/graphql.ts index 3a27061..71aa9a2 100644 --- a/src/graphql/types/graphql.ts +++ b/src/graphql/types/graphql.ts @@ -25457,6 +25457,11 @@ export type GetMainCategoriesQueryVariables = Exact<{ [key: string]: never; }>; export type GetMainCategoriesQuery = { __typename?: 'RootQuery', productCategories?: { __typename?: 'RootQueryToProductCategoryConnection', edges: Array<{ __typename?: 'RootQueryToProductCategoryConnectionEdge', node: { __typename?: 'ProductCategory', name?: string | null, id: number, image?: { __typename?: 'MediaItem', sourceUrl?: string | null, id: number } | null } }> } | null }; +export type GetGeneralSettingsQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetGeneralSettingsQuery = { __typename?: 'RootQuery', generalSettings?: { __typename?: 'GeneralSettings', title?: string | null, description?: string | null, timezone?: string | null, language?: string | null } | null }; + export type GetPageQueryVariables = Exact<{ slug?: InputMaybe; }>; @@ -25483,6 +25488,7 @@ export type GetHomePageSlidersQuery = { __typename?: 'RootQuery', sliderCategori export const CategoriesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Categories"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productCategories"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"id"},"name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","alias":{"kind":"Name","value":"parentId"},"name":{"kind":"Name","value":"parentDatabaseId"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetMainCategoriesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetMainCategories"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productCategories"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"parent"},"value":{"kind":"NullValue"}},{"kind":"ObjectField","name":{"kind":"Name","value":"orderby"},"value":{"kind":"EnumValue","value":"TERM_ORDER"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"id"},"name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"image"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"id"},"name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","name":{"kind":"Name","value":"sourceUrl"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; -export const GetPageDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPage"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"slug"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pages"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"name"},"value":{"kind":"Variable","name":{"kind":"Name","value":"slug"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetGeneralSettingsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGeneralSettings"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"generalSettings"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"timezone"}},{"kind":"Field","name":{"kind":"Name","value":"language"}}]}}]}}]} as unknown as DocumentNode; +export const GetPageDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPage"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"slug"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pages"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"name"},"value":{"kind":"Variable","name":{"kind":"Name","value":"slug"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"status"},"value":{"kind":"EnumValue","value":"PUBLISH"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const GetAllProductsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAllProducts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"stockStatus"}},"type":{"kind":"ListType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StockStatusEnum"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}},"type":{"kind":"ListType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ProductsOrderbyInput"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"categoryIdIn"}},"type":{"kind":"ListType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"q"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"products"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"stockStatus"},"value":{"kind":"Variable","name":{"kind":"Name","value":"stockStatus"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"orderby"},"value":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"categoryIdIn"},"value":{"kind":"Variable","name":{"kind":"Name","value":"categoryIdIn"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"search"},"value":{"kind":"Variable","name":{"kind":"Name","value":"q"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"total"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"VariableProduct"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"onSale"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"averageRating"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"image"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sourceUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"regularPrice"}},{"kind":"Field","name":{"kind":"Name","value":"salePrice"}},{"kind":"Field","name":{"kind":"Name","value":"stockStatus"}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const GetHomePageSlidersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetHomePageSliders"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sliderCategories"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"slug"},"value":{"kind":"StringValue","value":"homepage","block":false}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sliders"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"id"},"name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"featuredImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"id"},"name":{"kind":"Name","value":"databaseId"}},{"kind":"Field","alias":{"kind":"Name","value":"url"},"name":{"kind":"Name","value":"sourceUrl"}}]}}]}}]}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file