From 14570ea55c96e7305bd02339e13c3e3e1350a91e Mon Sep 17 00:00:00 2001 From: Ammar Mirza Date: Thu, 29 Aug 2024 11:42:37 +0530 Subject: [PATCH] Fixed page layout and deleted unnecessary components --- generated/graphq.ts | 193 +++++++++++------- src/app/[slug]/layout.tsx | 94 --------- src/app/[slug]/page.tsx | 38 ---- src/app/changelog/layout.tsx | 43 ---- src/app/changelog/page.tsx | 90 -------- src/app/global-error.tsx | 2 +- src/app/layout.tsx | 46 +++-- src/app/not-found.tsx | 2 +- src/app/page.tsx | 89 +++++++- .../{changelog => preview}/[slug]/layout.tsx | 0 .../{changelog => preview}/[slug]/page.tsx | 6 +- src/app/projects/page.tsx | 21 -- src/components/AboutMe.tsx | 73 ------- src/components/Blogs.tsx | 51 ----- src/components/ContactMe.tsx | 33 --- src/components/Navbar.tsx | 55 ----- src/components/Post.tsx | 2 +- src/components/PostHeader.tsx | 0 src/components/Projects.tsx | 31 --- src/components/SingleBlog.tsx | 54 ----- src/components/SingleProject.tsx | 80 -------- src/components/SocialLinks.tsx | 35 ---- src/schema_files/StaticPage.graphql | 21 -- src/utils/consts/index.tsx | 39 ---- 24 files changed, 228 insertions(+), 870 deletions(-) delete mode 100644 src/app/[slug]/layout.tsx delete mode 100644 src/app/[slug]/page.tsx delete mode 100644 src/app/changelog/layout.tsx delete mode 100644 src/app/changelog/page.tsx rename src/app/{changelog => preview}/[slug]/layout.tsx (100%) rename src/app/{changelog => preview}/[slug]/page.tsx (97%) delete mode 100644 src/app/projects/page.tsx delete mode 100644 src/components/AboutMe.tsx delete mode 100644 src/components/Blogs.tsx delete mode 100644 src/components/ContactMe.tsx delete mode 100644 src/components/Navbar.tsx delete mode 100644 src/components/PostHeader.tsx delete mode 100644 src/components/Projects.tsx delete mode 100644 src/components/SingleBlog.tsx delete mode 100644 src/components/SingleProject.tsx delete mode 100644 src/components/SocialLinks.tsx delete mode 100644 src/schema_files/StaticPage.graphql diff --git a/generated/graphq.ts b/generated/graphq.ts index d94c264..15f38b5 100644 --- a/generated/graphq.ts +++ b/generated/graphq.ts @@ -15,6 +15,7 @@ export type Scalars = { Int: { input: number; output: number; } Float: { input: number; output: number; } DateTime: { input: any; output: any; } + JSONObject: { input: any; output: any; } ObjectId: { input: any; output: any; } TimeZone: { input: any; output: any; } URL: { input: any; output: any; } @@ -1198,6 +1199,18 @@ export enum DeviceType { Tablet = 'TABLET' } +/** The input for disabling AI search for a documentation project */ +export type DisableDocumentationProjectAiSearchInput = { + /** The ID of the documentation project */ + projectId: Scalars['ID']['input']; +}; + +/** The response to disabling AI search for a documentation project */ +export type DisableDocumentationProjectAiSearchPayload = { + __typename?: 'DisableDocumentationProjectAISearchPayload'; + project?: Maybe; +}; + export type DisableDocumentationProjectHeadlessCmsInput = { projectId: Scalars['ID']['input']; }; @@ -1254,6 +1267,10 @@ export type DocsVisitors = { export type DocumentationApiReference = IGuide & { __typename?: 'DocumentationApiReference'; + /** The parsed Swagger Definition of the API Reference. */ + definition?: Maybe; + /** The base64 encoded gzip compressed string of the parsed OpenAPI Definition of the API Reference. */ + definitionV2?: Maybe; id: Scalars['ID']['output']; lastModified: Scalars['DateTime']['output']; name: Scalars['String']['output']; @@ -1417,6 +1434,7 @@ export type DocumentationPageDraft = { export type DocumentationProject = Node & { __typename?: 'DocumentationProject'; + ai?: Maybe; analytics: DocumentationProjectAnalytics; appearance: DocumentationProjectAppearance; createdAt: Scalars['DateTime']['output']; @@ -1445,6 +1463,7 @@ export type DocumentationProject = Node & { /** A user search to find users with a specific status */ searchUsers: DocumentationProjectSearchUserConnection; settings: DocumentationProjectSettings; + subscription?: Maybe; updatedAt?: Maybe; /** Url of the documentation project. */ url: Scalars['String']['output']; @@ -1480,6 +1499,30 @@ export type DocumentationProjectSearchUsersArgs = { input: DocumentationProjectSearchUsersInput; }; +export type DocumentationProjectAiPreference = { + __typename?: 'DocumentationProjectAIPreference'; + /** The prompts for the documentation project. These prompts are shown to the user when AI Search chatbot is opened. */ + prompts: Array; + /** The settings for the AI feature. */ + settings: DocumentationProjectAiSettings; +}; + +export type DocumentationProjectAiPrompt = { + __typename?: 'DocumentationProjectAIPrompt'; + /** The date the prompt was created. */ + createdAt: Scalars['DateTime']['output']; + /** The ID of the prompt. */ + id: Scalars['ID']['output']; + /** The prompt text. */ + prompt: Scalars['String']['output']; +}; + +export type DocumentationProjectAiSettings = { + __typename?: 'DocumentationProjectAISettings'; + /** A flag to indicate if the AI search feature is enabled. */ + isSearchEnabled: Scalars['Boolean']['output']; +}; + export type DocumentationProjectAnalytics = { __typename?: 'DocumentationProjectAnalytics'; views?: Maybe; @@ -1689,6 +1732,11 @@ export type DocumentationProjectPendingInviteConnection = PageConnection & { totalDocuments: Scalars['Int']['output']; }; +export enum DocumentationProjectProductName { + Enterprise = 'ENTERPRISE', + Startup = 'STARTUP' +} + /** A connection for the user search result. */ export type DocumentationProjectSearchUserConnection = PageConnection & { __typename?: 'DocumentationProjectSearchUserConnection'; @@ -1730,6 +1778,20 @@ export type DocumentationProjectSettingsInput = { allowRobots?: InputMaybe; }; +export type DocumentationProjectSubscription = { + __typename?: 'DocumentationProjectSubscription'; + nextBillingCycle?: Maybe; + productName: DocumentationProjectProductName; + status: DocumentationProjectSubscriptionStatus; +}; + +export enum DocumentationProjectSubscriptionStatus { + Active = 'ACTIVE', + Canceled = 'CANCELED', + PastDue = 'PAST_DUE', + Unpaid = 'UNPAID' +} + export type DocumentationSection = IDocumentationNestableSidebarItem & IDocumentationSidebarItem & { __typename?: 'DocumentationSection'; createdAt: Scalars['DateTime']['output']; @@ -1845,6 +1907,8 @@ export type Draft = Node & { /** The publication the draft belongs to. */ publication?: Maybe; publishAs?: Maybe; + /** Returns the published post when the draft is published, returns null otherwise */ + publishedPost?: Maybe; readTimeInMinutes: Scalars['Int']['output']; /** The date the draft is scheduled to be published. */ scheduledDate?: Maybe; @@ -2026,6 +2090,18 @@ export type EmailNotificationPreferences = { weeklyNewsletterEmails: Scalars['Boolean']['output']; }; +/** The input for enabling AI search for a documentation project */ +export type EnableDocumentationProjectAiSearchInput = { + /** The ID of the documentation project */ + projectId: Scalars['ID']['input']; +}; + +/** The response to enabling AI search for a documentation project */ +export type EnableDocumentationProjectAiSearchPayload = { + __typename?: 'EnableDocumentationProjectAISearchPayload'; + project?: Maybe; +}; + export type EnableDocumentationProjectHeadlessCmsInput = { projectId: Scalars['ID']['input']; }; @@ -2530,6 +2606,7 @@ export type IGuide = { id: Scalars['ID']['output']; lastModified: Scalars['DateTime']['output']; name: Scalars['String']['output']; + seo?: Maybe; slug: Scalars['String']['output']; versionId?: Maybe; }; @@ -2785,7 +2862,11 @@ export type Mutation = { /** Deletes a role based invite. */ deleteRoleBasedInvite: DeleteRoleBasedInvitePayload; deleteWebhook: DeleteWebhookPayload; + /** Mutation to disable AI search for a documentation project */ + disableDocumentationProjectAISearch: DisableDocumentationProjectAiSearchPayload; disableDocumentationProjectHeadlessCms: DisableDocumentationProjectHeadlessCmsPayload; + /** Mutation to enable AI search for a documentation project */ + enableDocumentationProjectAISearch: EnableDocumentationProjectAiSearchPayload; enableDocumentationProjectHeadlessCms: EnableDocumentationProjectHeadlessCmsPayload; /** * Will generate a authorization JWT to preview a docs project. @@ -2852,6 +2933,8 @@ export type Mutation = { scheduleDraft: ScheduleDraftPayload; setDocumentationSidebarItemVisibility: SetDocumentationSidebarItemVisibilityPayload; subscribeToNewsletter: SubscribeToNewsletterPayload; + /** Mutation to sync documentation API reference definition */ + syncDocumentationProjectApiDefinition: SyncDocumentationProjectApiDefinitionPayload; /** Toggle allowContributorEdits flag to allow or restrict external contributors to further edit published articles. */ toggleAllowContributorEdits: ToggleAllowContributorEditsPayload; /** @@ -2878,7 +2961,7 @@ export type Mutation = { updateDocumentationLink: UpdateDocumentationLinkPayload; updateDocumentationPageSettings: UpdateDocumentationPageSettingsPayload; updateDocumentationProjectSubdomain: UpdateDocumentationProjectSubdomainPayload; - /** Mutation to update a section in a guide */ + /** Mutation to update a section in a guide */ updateDocumentationSection: UpdateDocumentationSectionPayload; updatePost: UpdatePostPayload; updateRedirectionRule: UpdateRedirectionRulePayload; @@ -3013,11 +3096,21 @@ export type MutationDeleteWebhookArgs = { }; +export type MutationDisableDocumentationProjectAiSearchArgs = { + input: DisableDocumentationProjectAiSearchInput; +}; + + export type MutationDisableDocumentationProjectHeadlessCmsArgs = { input: DisableDocumentationProjectHeadlessCmsInput; }; +export type MutationEnableDocumentationProjectAiSearchArgs = { + input: EnableDocumentationProjectAiSearchInput; +}; + + export type MutationEnableDocumentationProjectHeadlessCmsArgs = { input: EnableDocumentationProjectHeadlessCmsInput; }; @@ -3218,6 +3311,11 @@ export type MutationSubscribeToNewsletterArgs = { }; +export type MutationSyncDocumentationProjectApiDefinitionArgs = { + input: SyncDocumentationProjectApiDefinitionInput; +}; + + export type MutationToggleAllowContributorEditsArgs = { input: ToggleAllowContributorEditsInput; }; @@ -5664,6 +5762,23 @@ export type SubscribeToNewsletterPayload = { status?: Maybe; }; +/** The input for syncing API reference definitions */ +export type SyncDocumentationProjectApiDefinitionInput = { + /** The ID of the docs API reference */ + apiReferenceId: Scalars['ID']['input']; + /** The ID of the documentation project */ + projectId: Scalars['ID']['input']; + /** The ID of the reference version */ + versionId: Scalars['ID']['input']; +}; + +/** The response to syncing documentation project API Reference definition */ +export type SyncDocumentationProjectApiDefinitionPayload = { + __typename?: 'SyncDocumentationProjectApiDefinitionPayload'; + /** Signifies if the mutation was successful. */ + success: Scalars['Boolean']['output']; +}; + export type TableOfContentsFeature = Feature & { __typename?: 'TableOfContentsFeature'; /** Whether or not the user has chosen to show a table of contents on the post. */ @@ -6626,14 +6741,6 @@ export type PublicationQueryVariables = Exact<{ export type PublicationQuery = { __typename?: 'Query', publication?: { __typename?: 'Publication', id: string, descriptionSEO?: string | null, displayTitle?: string | null, title: string, isTeam: boolean, favicon?: string | null, followersCount?: number | null, preferences: { __typename?: 'Preferences', logo?: string | null }, ogMetaData: { __typename?: 'OpenGraphMetaData', image?: string | null }, links?: { __typename?: 'PublicationLinks', twitter?: string | null, instagram?: string | null, github?: string | null, website?: string | null, hashnode?: string | null, youtube?: string | null, linkedin?: string | null, mastodon?: string | null } | null, posts: { __typename?: 'PublicationPostConnection', edges: Array<{ __typename?: 'PostEdge', node: { __typename?: 'Post', id: string, slug: string, title: string, brief: string, coverImage?: { __typename?: 'PostCoverImage', url: string } | null } }> }, author: { __typename?: 'User', name: string, profilePicture?: string | null, location?: string | null, bio?: { __typename?: 'Content', html: string, text: string } | null } } | null }; -export type StaticPageQueryVariables = Exact<{ - host?: InputMaybe; - slug: Scalars['String']['input']; -}>; - - -export type StaticPageQuery = { __typename?: 'Query', publication?: { __typename?: 'Publication', staticPage?: { __typename?: 'StaticPage', id: string, title: string, slug: string, hidden: boolean, content: { __typename?: 'Content', markdown: string, html: string }, ogMetaData?: { __typename?: 'OpenGraphMetaData', image?: string | null } | null, seo?: { __typename?: 'SEO', title?: string | null, description?: string | null } | null } | null } | null }; - export const PostDocument = ` @@ -6905,71 +7012,3 @@ useInfinitePublicationQuery.getKey = (variables?: PublicationQueryVariables) => usePublicationQuery.fetcher = (variables?: PublicationQueryVariables, options?: RequestInit['headers']) => fetchData(PublicationDocument, variables, options); - -export const StaticPageDocument = ` - query StaticPage($host: String, $slug: String!) { - publication(host: $host) { - staticPage(slug: $slug) { - id - title - slug - content { - markdown - html - } - hidden - ogMetaData { - image - } - seo { - title - description - } - } - } -} - `; - -export const useStaticPageQuery = < - TData = StaticPageQuery, - TError = unknown - >( - variables: StaticPageQueryVariables, - options?: Omit, 'queryKey'> & { queryKey?: UseQueryOptions['queryKey'] } - ) => { - - return useQuery( - { - queryKey: ['StaticPage', variables], - queryFn: fetchData(StaticPageDocument, variables), - ...options - } - )}; - -useStaticPageQuery.document = StaticPageDocument; - -useStaticPageQuery.getKey = (variables: StaticPageQueryVariables) => ['StaticPage', variables]; - -export const useInfiniteStaticPageQuery = < - TData = InfiniteData, - TError = unknown - >( - variables: StaticPageQueryVariables, - options: Omit, 'queryKey'> & { queryKey?: UseInfiniteQueryOptions['queryKey'] } - ) => { - - return useInfiniteQuery( - (() => { - const { queryKey: optionsQueryKey, ...restOptions } = options; - return { - queryKey: optionsQueryKey ?? ['StaticPage.infinite', variables], - queryFn: (metaData) => fetchData(StaticPageDocument, {...variables, ...(metaData.pageParam ?? {})})(), - ...restOptions - } - })() - )}; - -useInfiniteStaticPageQuery.getKey = (variables: StaticPageQueryVariables) => ['StaticPage.infinite', variables]; - - -useStaticPageQuery.fetcher = (variables: StaticPageQueryVariables, options?: RequestInit['headers']) => fetchData(StaticPageDocument, variables, options); diff --git a/src/app/[slug]/layout.tsx b/src/app/[slug]/layout.tsx deleted file mode 100644 index 0ad9af9..0000000 --- a/src/app/[slug]/layout.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import getQueryClient from '@/utils/getQueryClient'; -import { StaticPageQuery, useStaticPageQuery } from '../../../generated/graphq'; -import { dehydrate, HydrationBoundary } from '@tanstack/react-query'; -import Script from 'next/script'; -import { Metadata, ResolvingMetadata } from 'next'; -import { notFound } from 'next/navigation'; -const host = process.env.NEXT_PUBLIC_HASHNODE_PUBLICATION_HOST as string; - -interface StaticPageLayoutProps { - children: React.ReactNode; - params: { - slug: string; - }; -} - -interface Props { - params: { - slug: string; - }; -} - -export async function generateMetadata( - props: Props, - parent: ResolvingMetadata -): Promise { - const queryClient = getQueryClient(); - - await queryClient.prefetchQuery({ - queryKey: useStaticPageQuery.getKey({ - host, - slug: props.params.slug, - }), - queryFn: useStaticPageQuery.fetcher({ - host, - slug: props.params.slug, - }), - }); - const data = queryClient.getQueryData( - useStaticPageQuery.getKey({ - host, - slug: props.params.slug, - }) - ); - - const page = data?.publication?.staticPage; - - if (!page) - return { - title: '404 not found', - }; - - return { - title: page.seo?.title || page.title, - description: page.seo?.description, - openGraph: { - title: page.seo?.title!, - description: page.seo?.description!, - images: [ - { - url: page.ogMetaData?.image!, - width: 1200, - height: 630, - }, - ], - }, - }; -} - -export default async function StaticPageLayoutProps({ - children, - params, -}: StaticPageLayoutProps) { - const queryClient = getQueryClient(); - - await queryClient.prefetchQuery({ - queryKey: useStaticPageQuery.getKey({ - host, - slug: params.slug, - }), - queryFn: useStaticPageQuery.fetcher({ - host, - slug: params.slug, - }), - }); - - return ( - <> - - {children} - -