From 351aa3a1b0757316d410c6077cf977f37c9e3163 Mon Sep 17 00:00:00 2001 From: moransantiago Date: Thu, 2 May 2024 14:03:32 -0300 Subject: [PATCH 1/2] Remove heading with icon --- .../heading-with-icon.module.scss | 13 ------- .../article/heading-with-icon/index.tsx | 34 ------------------- app/_components/article/index.tsx | 2 -- basehub-helpers/fragments.ts | 2 -- 4 files changed, 51 deletions(-) delete mode 100644 app/_components/article/heading-with-icon/heading-with-icon.module.scss delete mode 100644 app/_components/article/heading-with-icon/index.tsx diff --git a/app/_components/article/heading-with-icon/heading-with-icon.module.scss b/app/_components/article/heading-with-icon/heading-with-icon.module.scss deleted file mode 100644 index 6163ef1..0000000 --- a/app/_components/article/heading-with-icon/heading-with-icon.module.scss +++ /dev/null @@ -1,13 +0,0 @@ -.heading-icon { - position: absolute; - left: calc(var(--space-7) * -1); - top: 50%; - transform: translateY(-50%); - height: var(--space-4); - width: var(--space-4); - - @media screen and (min-width: 1024px) { - height: var(--space-5); - width: var(--space-5); - } -} \ No newline at end of file diff --git a/app/_components/article/heading-with-icon/index.tsx b/app/_components/article/heading-with-icon/index.tsx deleted file mode 100644 index f5de3c7..0000000 --- a/app/_components/article/heading-with-icon/index.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { fragmentOn } from '@/.basehub' -import Image from 'next/image' - -import s from './heading-with-icon.module.scss' - -export const HeadingWithIconMark = ({ - icon, - children, -}: HeadingWithIconFragment & { children?: React.ReactNode }) => { - return ( - <> - {icon.alt - {children} - - ) -} - -export const HeadingWithIconFragment = fragmentOn('HeadingWithIconComponent', { - _id: true, - icon: { - alt: true, - width: true, - height: true, - url: true, - }, -}) - -type HeadingWithIconFragment = fragmentOn.infer diff --git a/app/_components/article/index.tsx b/app/_components/article/index.tsx index 6e87494..648aa81 100644 --- a/app/_components/article/index.tsx +++ b/app/_components/article/index.tsx @@ -16,7 +16,6 @@ import { RichText, RichTextProps } from '@/.basehub/react-rich-text' import { Pump } from '@/.basehub/react-pump' import { Box, Code, Table, Text } from '@radix-ui/themes' -import { HeadingWithIconMark } from './heading-with-icon' import { CalloutComponent } from './callout' import { StepperComponent } from './stepper' import { CardsGridComponent } from './cards-grid' @@ -192,7 +191,6 @@ export const Body = (props: RichTextProps) => { CalloutComponent, CardsGridComponent, CardsGridComponent_mark: CardsGridComponent, - HeadingWithIconComponent_mark: HeadingWithIconMark, video: Video, img: Image, CodeSnippetComponent: CodeSnippetSingle, diff --git a/basehub-helpers/fragments.ts b/basehub-helpers/fragments.ts index fed6ce6..f14058b 100644 --- a/basehub-helpers/fragments.ts +++ b/basehub-helpers/fragments.ts @@ -7,7 +7,6 @@ import { CodeGroupFragment, CodeSnippetFragmentRecursive, } from '@/app/_components/article/code-snippet' -import { HeadingWithIconFragment } from '@/app/_components/article/heading-with-icon' import { StepperFragment } from '@/app/_components/article/stepper' /* ------------------------------------------------------------------------------------------------- @@ -36,7 +35,6 @@ export const ArticleBodyFragment = fragmentOn('BodyRichText', { blocks: { __typename: true, on_CalloutComponent: CalloutFragment, - on_HeadingWithIconComponent: HeadingWithIconFragment, on_CardsGridComponent: CardsGridFragment, on_AccordionGroupComponent: AccordionGroupFragment, on_StepperComponent: StepperFragment, From 1cb244bc8b79e75decebb4d6ff1df573b2091f3f Mon Sep 17 00:00:00 2001 From: moransantiago Date: Fri, 31 May 2024 11:37:05 -0300 Subject: [PATCH 2/2] Remove unnecessary api routes --- app/[category]/[[...slug]]/page.tsx | 2 +- app/api/draft/disable/route.ts | 6 ---- app/api/draft/enable/route.ts | 44 ----------------------------- package.json | 2 +- pnpm-lock.yaml | 14 ++++----- 5 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 app/api/draft/disable/route.ts delete mode 100644 app/api/draft/enable/route.ts diff --git a/app/[category]/[[...slug]]/page.tsx b/app/[category]/[[...slug]]/page.tsx index 43930db..7c7f8fb 100644 --- a/app/[category]/[[...slug]]/page.tsx +++ b/app/[category]/[[...slug]]/page.tsx @@ -79,7 +79,7 @@ export const generateMetadata = async ({ if (!params.slug?.length) { const title = `${category._title} ${data.settings.metadata.pageTitleTemplate}` const description = siteName + ' documentation / ' + category._title - console.log(process.env) + const images = [ { url: `/dynamic-og?article=${category._id}&type=category`, diff --git a/app/api/draft/disable/route.ts b/app/api/draft/disable/route.ts deleted file mode 100644 index 71f91a2..0000000 --- a/app/api/draft/disable/route.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { draftMode } from 'next/headers' - -export async function POST() { - draftMode().disable() - return new Response('Draft mode is disabled') -} diff --git a/app/api/draft/enable/route.ts b/app/api/draft/enable/route.ts deleted file mode 100644 index e0c663d..0000000 --- a/app/api/draft/enable/route.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { basehub } from '@/.basehub' -import { getAritcleSlugFromSlugPath } from '@/basehub-helpers/util' -import { draftMode } from 'next/headers' -import { redirect } from 'next/navigation' - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const secret = searchParams.get('secret') - - if (secret !== 'TODO_SECRET') { - return new Response('Invalid token', { status: 401 }) - } - - draftMode().enable() - - let redirectTo = '/' - const next = searchParams.get('next') - const articleId = searchParams.get('article') - if (next) { - // prevent open redirect attacks - const parsedNext = new URL(next, request.url) - redirectTo = parsedNext.pathname + parsedNext.search + parsedNext.hash - } else if (articleId) { - const data = await basehub({ draft: true }).query({ - _componentInstances: { - article: { - __args: { first: 1, filter: { _sys_id: { eq: articleId } } }, - items: { - _slugPath: true, - }, - }, - }, - }) - - const article = data._componentInstances.article.items[0] - if (article) { - // _slugPath will have something like root/pages//articles//children//children/... - // remove root/pages and then filter out every other part - redirectTo = getAritcleSlugFromSlugPath(article._slugPath) - } - } - - redirect(redirectTo) -} diff --git a/package.json b/package.json index 5ca2db0..01ff141 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@radix-ui/react-icons": "^1.3.0", "@radix-ui/themes": "^3.0.2", "@shikijs/transformers": "^1.3.0", - "basehub": "5.1.1-canary.2", + "basehub": "5.2.2", "clsx": "^2.1.1", "geist": "^1.3.0", "hast-util-to-jsx-runtime": "^2.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e75298..36e1e53 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ dependencies: specifier: ^1.3.0 version: 1.6.1 basehub: - specifier: 5.1.1-canary.2 - version: 5.1.1-canary.2(@babel/runtime@7.24.6)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(typescript@5.4.5) + specifier: 5.2.2 + version: 5.2.2(@babel/runtime@7.24.6)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(typescript@5.4.5) clsx: specifier: ^2.1.1 version: 2.1.1 @@ -88,8 +88,8 @@ packages: dependencies: regenerator-runtime: 0.14.1 - /@basehub/genql@7.0.8: - resolution: {integrity: sha512-vVHkAPdiIxKptciTrwIhhlChyWnGxKjYN0nuj50pWQ/ZSz7UheDyAB9RPWKJU4qdCkKpQ9urjruddEXvPMfTaQ==} + /@basehub/genql@8.0.0: + resolution: {integrity: sha512-hR7dKm/TCDf2PzRcOUhCKYlYJP2QAmULPWWyHt6EOzf+d5mNiXbsKxq0EFTS0AbakwVc69QWPZZfIS9KyKlqfQ==} dependencies: '@graphql-tools/graphql-file-loader': 7.5.17(graphql@16.8.1) '@graphql-tools/load': 7.8.14(graphql@16.8.1) @@ -2423,14 +2423,14 @@ packages: /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - /basehub@5.1.1-canary.2(@babel/runtime@7.24.6)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(typescript@5.4.5): - resolution: {integrity: sha512-haSLGSbYBEU/5OgkHxmCTeVHkzNuZsX3ymvGZr8X5PSsG04U1HN/z+p5WXK5pdiExx/+voPMY2+bOaG3b/PshQ==} + /basehub@5.2.2(@babel/runtime@7.24.6)(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1)(typescript@5.4.5): + resolution: {integrity: sha512-7iONBImT3ICpa2SeN4GRLQtOxEO1wQTQEEhwntYZFE14UAwMcpKuSWtnhhN0IBU6XwILJGo3OJ9u3XKA0mEW8w==} hasBin: true peerDependencies: react: ^18.2.0 react-dom: ^18.2.0 dependencies: - '@basehub/genql': 7.0.8 + '@basehub/genql': 8.0.0 '@basehub/mutation-api-helpers': 1.0.5 '@radix-ui/react-slot': 1.0.2(@types/react@18.3.3)(react@18.3.1) arg: 5.0.1