diff --git a/gatsby/cloud-plan.ts b/gatsby/cloud-plan.ts index 37032a26..fd2e9c49 100644 --- a/gatsby/cloud-plan.ts +++ b/gatsby/cloud-plan.ts @@ -1,7 +1,7 @@ import { mdxAstToToc, TocQueryData } from "./toc"; import { generateConfig } from "./path"; import { extractFilesFromToc } from "./toc-filter"; -import { CloudPlan } from "shared/useCloudPlan"; +import { CloudPlan } from "shared/interface"; type TocMap = Map< string, diff --git a/gatsby/create-pages.ts b/gatsby/create-pages.ts deleted file mode 100644 index a44c2921..00000000 --- a/gatsby/create-pages.ts +++ /dev/null @@ -1,366 +0,0 @@ -import { resolve } from "path"; - -import type { CreatePagesArgs } from "gatsby"; -import sig from "signale"; - -import { Locale, Repo, BuildType } from "../src/shared/interface"; -import { - generateConfig, - generateUrl, - generateNav, - generateDocHomeUrl, - generateStarterNav, - generateEssentialNav, -} from "./path"; -import { docs as DOCS_CONFIG } from "../docs/docs.json"; -import { cpMarkdown } from "./cp-markdown"; -import { - getTidbCloudFilesFromTocs, - determineInDefaultPlan, -} from "./cloud-plan"; -import { getFilesFromTocs, filterNodesByToc } from "./toc-filter"; - -interface PageQueryData { - allMdx: { - nodes: { - id: string; - frontmatter: { aliases: string[] }; - slug: string; - }[]; - }; -} - -const DEFAULT_BUILD_TYPE: BuildType = "prod"; - -export const createDocs = async (createPagesArgs: CreatePagesArgs) => { - const { - actions: { createPage, createRedirect }, - graphql, - } = createPagesArgs; - // const template = resolve(__dirname, '../src/doc/index.tsx') - const template = resolve(__dirname, "../src/templates/DocTemplate.tsx"); - - // First, get the list of files that should be built based on TOC content - const tocFilesMap = await getFilesFromTocs(graphql); - - // Get tidbcloud specific TOC files for plan determination - const tidbCloudTocFilesMap = await getTidbCloudFilesFromTocs(graphql); - - const docs = await graphql(` - { - allMdx( - filter: { - fileAbsolutePath: { regex: "/^(?!.*TOC).*$/" } - slug: { - nin: ["en/tidb/_docHome", "zh/tidb/_docHome", "ja/tidb/_docHome"] - } - frontmatter: { draft: { ne: true } } - } - ) { - nodes { - id - frontmatter { - aliases - } - slug - parent { - ... on File { - relativePath - } - } - } - } - } - `); - - if (docs.errors) { - sig.error(docs.errors); - } - - const nodes = filterNodesByToc( - docs.data!.allMdx.nodes.map((node) => { - const { config, name, filePath } = generateConfig(node.slug); - return { ...node, pathConfig: config, name, filePath }; - }), - tocFilesMap - ); - - sig.info( - `Building ${nodes.length} files after TOC filtering (from ${ - docs.data!.allMdx.nodes.length - } total files)` - ); - - // Log some statistics about the filtering - const filteredByToc = docs.data!.allMdx.nodes.length - nodes.length; - if (filteredByToc > 0) { - sig.info(`Filtered out ${filteredByToc} files not referenced in TOCs`); - } - - const versionRecord = nodes.reduce( - (acc, { pathConfig, name }) => { - if (acc[pathConfig.locale][pathConfig.repo] == null) { - acc[pathConfig.locale][pathConfig.repo] = {}; - } - - if (acc[pathConfig.locale][pathConfig.repo][name] == null) { - acc[pathConfig.locale][pathConfig.repo][name] = []; - } - - acc[pathConfig.locale][pathConfig.repo][name].push(pathConfig.version); - - return acc; - }, - { - en: {} as Record>, - zh: {} as Record>, - ja: {} as Record>, - } - ); - - nodes.forEach((node) => { - const { id, name, pathConfig, filePath } = node; - - if (name?.startsWith("_")) { - return; - } - - const path = generateUrl(name, pathConfig); - const navUrl = generateNav(pathConfig); - const starterNavUrl = generateStarterNav(pathConfig); - const essentialNavUrl = generateEssentialNav(pathConfig); - - const locale = [Locale.en, Locale.zh, Locale.ja] - .map((l) => - versionRecord[l][pathConfig.repo]?.[name]?.includes(pathConfig.version) - ? l - : undefined - ) - .filter(Boolean); - - // Determine inDefaultPlan for tidbcloud articles - const inDefaultPlan = determineInDefaultPlan( - name, - pathConfig, - tidbCloudTocFilesMap - ); - - cpMarkdown(`${node.slug}.md`, path, name); - createPage({ - path, - component: template, - context: { - id, - name, - pathConfig, - // use for edit in github - filePath, - pageUrl: path, - navUrl, - starterNavUrl, - essentialNavUrl, - availIn: { - locale, - version: versionRecord[pathConfig.locale][pathConfig.repo][name], - }, - buildType: (process.env.WEBSITE_BUILD_TYPE ?? - DEFAULT_BUILD_TYPE) as BuildType, // prod | archive, default is prod; archive is for archive site - feature: { - banner: true, - feedback: true, - }, - inDefaultPlan, - }, - }); - - // create redirects - if (node.frontmatter.aliases) { - node.frontmatter.aliases.forEach((fromPath: string) => { - createRedirect({ - fromPath, - toPath: path, - isPermanent: true, - }); - }); - } - }); -}; - -export const createCloudAPIReference = async ({ - actions: { createPage, createRedirect }, - graphql, -}: CreatePagesArgs) => { - const template = resolve( - __dirname, - "../src/templates/CloudAPIReferenceTemplate.tsx" - ); - const pageCfg = DOCS_CONFIG.tidbcloud.openAPI; - const pageList = pageCfg.data; - const locale = [Locale.en]; - - pageList.forEach((page) => { - const path = `/tidbcloud/${pageCfg.path}/${page.pathname}`; - const isProduction = process.env.CI === "true"; - createPage({ - path, - component: template, - context: { - ...page, - isProduction, - availIn: { - locale, - version: [], - }, - buildType: (process.env.WEBSITE_BUILD_TYPE ?? - DEFAULT_BUILD_TYPE) as BuildType, - feature: { - banner: false, - }, - }, - }); - }); -}; - -export const createDocHome = async ({ - actions: { createPage, createRedirect }, - graphql, -}: CreatePagesArgs) => { - // const template = resolve(__dirname, "../src/doc/index.tsx"); - const template = resolve(__dirname, "../src/templates/DocTemplate.tsx"); - - const prodQueryStr = ` - { - allMdx( - filter: { - fileAbsolutePath: { regex: "/tidb/master/_docHome.md$/" } - frontmatter: { draft: { ne: true } } - } - ) { - nodes { - id - frontmatter { - aliases - } - slug - parent { - ... on File { - relativePath - } - } - } - } - } -`; - - const archiveQueryStr = ` - { - allMdx( - filter: { - fileAbsolutePath: { regex: "/tidb/_docHome.md$/" } - frontmatter: { draft: { ne: true } } - } - ) { - nodes { - id - frontmatter { - aliases - } - slug - parent { - ... on File { - relativePath - } - } - } - } - } -`; - - const docs = await graphql( - process.env.WEBSITE_BUILD_TYPE === "archive" - ? archiveQueryStr - : prodQueryStr - ); - - if (docs.errors) { - sig.error(docs.errors); - } - - const nodes = docs.data!.allMdx.nodes.map((node) => { - const { config, name, filePath } = generateConfig(node.slug); - return { ...node, pathConfig: config, name, filePath }; - }); - - nodes.forEach((node) => { - const { id, name, pathConfig, filePath, slug } = node; - const path = generateDocHomeUrl(name, pathConfig); - const navUrl = generateNav(pathConfig); - const starterNavUrl = generateStarterNav(pathConfig); - const essentialNavUrl = generateEssentialNav(pathConfig); - const locale = - process.env.WEBSITE_BUILD_TYPE === "archive" - ? [Locale.en, Locale.zh] - : [Locale.en, Locale.zh, Locale.ja]; - - createPage({ - path, - component: template, - context: { - id, - name, - pathConfig, - // use for edit in github - filePath, - navUrl, - starterNavUrl, - essentialNavUrl, - pageUrl: path, - availIn: { - locale, - version: [], - }, - buildType: (process.env.WEBSITE_BUILD_TYPE ?? - DEFAULT_BUILD_TYPE) as BuildType, - feature: { - banner: true, - feedback: true, - globalHome: true, - }, - }, - }); - }); -}; - -export const createDocSearch = async ({ - actions: { createPage }, -}: CreatePagesArgs) => { - const template = resolve(__dirname, "../src/templates/DocSearchTemplate.tsx"); - - createPage({ - path: "/search/", - component: template, - context: { - feature: { - banner: false, - }, - }, - }); -}; - -export const create404 = async ({ - actions: { createPage }, -}: CreatePagesArgs) => { - const template = resolve(__dirname, "../src/templates/404Template.tsx"); - - createPage({ - path: "/404/", - component: template, - context: { - buildType: (process.env.WEBSITE_BUILD_TYPE ?? - DEFAULT_BUILD_TYPE) as BuildType, - feature: { - banner: false, - }, - }, - }); -}; diff --git a/gatsby/create-pages/create-404.ts b/gatsby/create-pages/create-404.ts new file mode 100644 index 00000000..14087517 --- /dev/null +++ b/gatsby/create-pages/create-404.ts @@ -0,0 +1,22 @@ +import { resolve } from "path"; +import type { CreatePagesArgs } from "gatsby"; +import { DEFAULT_BUILD_TYPE } from "./interface"; +import { BuildType } from "../../src/shared/interface"; + +export const create404 = async ({ + actions: { createPage }, +}: CreatePagesArgs) => { + const template = resolve(__dirname, "../../src/templates/404Template.tsx"); + + createPage({ + path: "/404/", + component: template, + context: { + buildType: (process.env.WEBSITE_BUILD_TYPE ?? + DEFAULT_BUILD_TYPE) as BuildType, + feature: { + banner: false, + }, + }, + }); +}; diff --git a/gatsby/create-pages/create-cloud-api.ts b/gatsby/create-pages/create-cloud-api.ts new file mode 100644 index 00000000..41d5f73f --- /dev/null +++ b/gatsby/create-pages/create-cloud-api.ts @@ -0,0 +1,41 @@ +import { resolve } from "path"; + +import type { CreatePagesArgs } from "gatsby"; + +import { Locale, BuildType } from "../../src/shared/interface"; +import { docs as DOCS_CONFIG } from "../../docs/docs.json"; +import { DEFAULT_BUILD_TYPE } from "./interface"; + +export const createCloudAPIReference = async ({ + actions: { createPage }, +}: CreatePagesArgs) => { + const template = resolve( + __dirname, + "../../src/templates/CloudAPIReferenceTemplate.tsx" + ); + const pageCfg = DOCS_CONFIG.tidbcloud.openAPI; + const pageList = pageCfg.data; + const locale = [Locale.en]; + + pageList.forEach((page) => { + const path = `/tidbcloud/${pageCfg.path}/${page.pathname}`; + const isProduction = process.env.CI === "true"; + createPage({ + path, + component: template, + context: { + ...page, + isProduction, + availIn: { + locale, + version: [], + }, + buildType: (process.env.WEBSITE_BUILD_TYPE ?? + DEFAULT_BUILD_TYPE) as BuildType, + feature: { + banner: false, + }, + }, + }); + }); +}; diff --git a/gatsby/create-pages/create-doc-home.ts b/gatsby/create-pages/create-doc-home.ts new file mode 100644 index 00000000..76f5618c --- /dev/null +++ b/gatsby/create-pages/create-doc-home.ts @@ -0,0 +1,124 @@ +import { resolve } from "path"; + +import type { CreatePagesArgs } from "gatsby"; +import sig from "signale"; + +import { Locale, BuildType } from "../../src/shared/interface"; +import { + generateConfig, + generateNav, + generateDocHomeUrl, + generateStarterNav, + generateEssentialNav, +} from "../../gatsby/path"; +import { DEFAULT_BUILD_TYPE, PageQueryData } from "./interface"; + +export const createDocHome = async ({ + actions: { createPage }, + graphql, +}: CreatePagesArgs) => { + // const template = resolve(__dirname, "../src/doc/index.tsx"); + const template = resolve(__dirname, "../../src/templates/DocTemplate.tsx"); + + const prodQueryStr = ` + { + allMdx( + filter: { + fileAbsolutePath: { regex: "/tidb/master/_docHome.md$/" } + frontmatter: { draft: { ne: true } } + } + ) { + nodes { + id + frontmatter { + aliases + } + slug + parent { + ... on File { + relativePath + } + } + } + } + } +`; + + const archiveQueryStr = ` + { + allMdx( + filter: { + fileAbsolutePath: { regex: "/tidb/_docHome.md$/" } + frontmatter: { draft: { ne: true } } + } + ) { + nodes { + id + frontmatter { + aliases + } + slug + parent { + ... on File { + relativePath + } + } + } + } + } +`; + + const docs = await graphql( + process.env.WEBSITE_BUILD_TYPE === "archive" + ? archiveQueryStr + : prodQueryStr + ); + + if (docs.errors) { + sig.error(docs.errors); + } + + const nodes = docs.data!.allMdx.nodes.map((node) => { + const { config, name, filePath } = generateConfig(node.slug); + return { ...node, pathConfig: config, name, filePath }; + }); + + nodes.forEach((node) => { + const { id, name, pathConfig, filePath, slug } = node; + const path = generateDocHomeUrl(name, pathConfig); + const navUrl = generateNav(pathConfig); + const starterNavUrl = generateStarterNav(pathConfig); + const essentialNavUrl = generateEssentialNav(pathConfig); + const locale = + process.env.WEBSITE_BUILD_TYPE === "archive" + ? [Locale.en, Locale.zh] + : [Locale.en, Locale.zh, Locale.ja]; + + createPage({ + path, + component: template, + context: { + id, + name, + pathConfig, + // use for edit in github + filePath, + navUrl, + starterNavUrl, + essentialNavUrl, + pageUrl: path, + availIn: { + locale, + version: [], + }, + buildType: (process.env.WEBSITE_BUILD_TYPE ?? + DEFAULT_BUILD_TYPE) as BuildType, + feature: { + banner: true, + feedback: true, + globalHome: true, + }, + }, + }); + }); +}; diff --git a/gatsby/create-pages/create-docs.ts b/gatsby/create-pages/create-docs.ts new file mode 100644 index 00000000..ca266fbf --- /dev/null +++ b/gatsby/create-pages/create-docs.ts @@ -0,0 +1,174 @@ +import { resolve } from "path"; + +import type { CreatePagesArgs } from "gatsby"; +import sig from "signale"; + +import { Locale, Repo, BuildType } from "../../src/shared/interface"; +import { + generateConfig, + generateUrl, + generateNav, + generateStarterNav, + generateEssentialNav, +} from "../../gatsby/path"; +import { cpMarkdown } from "../../gatsby/cp-markdown"; +import { + getTidbCloudFilesFromTocs, + determineInDefaultPlan, +} from "../cloud-plan"; +import { getFilesFromTocs, filterNodesByToc } from "../toc-filter"; +import { PageQueryData, DEFAULT_BUILD_TYPE } from "./interface"; + +export const createDocs = async (createPagesArgs: CreatePagesArgs) => { + const { + actions: { createPage, createRedirect }, + graphql, + } = createPagesArgs; + // const template = resolve(__dirname, '../src/doc/index.tsx') + const template = resolve(__dirname, "../../src/templates/DocTemplate.tsx"); + + // First, get the list of files that should be built based on TOC content + const tocFilesMap = await getFilesFromTocs(graphql); + + // Get tidbcloud specific TOC files for plan determination + const tidbCloudTocFilesMap = await getTidbCloudFilesFromTocs(graphql); + + const docs = await graphql(` + { + allMdx( + filter: { + fileAbsolutePath: { regex: "/^(?!.*TOC).*$/" } + slug: { + nin: ["en/tidb/_docHome", "zh/tidb/_docHome", "ja/tidb/_docHome"] + } + frontmatter: { draft: { ne: true } } + } + ) { + nodes { + id + frontmatter { + aliases + } + slug + parent { + ... on File { + relativePath + } + } + } + } + } + `); + + if (docs.errors) { + sig.error(docs.errors); + } + + const nodes = filterNodesByToc( + docs.data!.allMdx.nodes.map((node) => { + const { config, name, filePath } = generateConfig(node.slug); + return { ...node, pathConfig: config, name, filePath }; + }), + tocFilesMap + ); + + sig.info( + `Building ${nodes.length} files after TOC filtering (from ${ + docs.data!.allMdx.nodes.length + } total files)` + ); + + // Log some statistics about the filtering + const filteredByToc = docs.data!.allMdx.nodes.length - nodes.length; + if (filteredByToc > 0) { + sig.info(`Filtered out ${filteredByToc} files not referenced in TOCs`); + } + + const versionRecord = nodes.reduce( + (acc, { pathConfig, name }) => { + if (acc[pathConfig.locale][pathConfig.repo] == null) { + acc[pathConfig.locale][pathConfig.repo] = {}; + } + + if (acc[pathConfig.locale][pathConfig.repo][name] == null) { + acc[pathConfig.locale][pathConfig.repo][name] = []; + } + + acc[pathConfig.locale][pathConfig.repo][name].push(pathConfig.version); + + return acc; + }, + { + en: {} as Record>, + zh: {} as Record>, + ja: {} as Record>, + } + ); + + nodes.forEach((node) => { + const { id, name, pathConfig, filePath } = node; + + if (name?.startsWith("_")) { + return; + } + + const path = generateUrl(name, pathConfig); + const navUrl = generateNav(pathConfig); + const starterNavUrl = generateStarterNav(pathConfig); + const essentialNavUrl = generateEssentialNav(pathConfig); + + const locale = [Locale.en, Locale.zh, Locale.ja] + .map((l) => + versionRecord[l][pathConfig.repo]?.[name]?.includes(pathConfig.version) + ? l + : undefined + ) + .filter(Boolean); + + // Determine inDefaultPlan for tidbcloud articles + const inDefaultPlan = determineInDefaultPlan( + name, + pathConfig, + tidbCloudTocFilesMap + ); + + cpMarkdown(`${node.slug}.md`, path, name); + createPage({ + path, + component: template, + context: { + id, + name, + pathConfig, + // use for edit in github + filePath, + pageUrl: path, + navUrl, + starterNavUrl, + essentialNavUrl, + availIn: { + locale, + version: versionRecord[pathConfig.locale][pathConfig.repo][name], + }, + buildType: (process.env.WEBSITE_BUILD_TYPE ?? + DEFAULT_BUILD_TYPE) as BuildType, // prod | archive, default is prod; archive is for archive site + feature: { + banner: true, + feedback: true, + }, + inDefaultPlan, + }, + }); + + // create redirects + if (node.frontmatter.aliases) { + node.frontmatter.aliases.forEach((fromPath: string) => { + createRedirect({ + fromPath, + toPath: path, + isPermanent: true, + }); + }); + } + }); +}; diff --git a/gatsby/create-pages/create-search.ts b/gatsby/create-pages/create-search.ts new file mode 100644 index 00000000..3fd6c571 --- /dev/null +++ b/gatsby/create-pages/create-search.ts @@ -0,0 +1,21 @@ +import { resolve } from "path"; +import type { CreatePagesArgs } from "gatsby"; + +export const createDocSearch = async ({ + actions: { createPage }, +}: CreatePagesArgs) => { + const template = resolve( + __dirname, + "../../src/templates/DocSearchTemplate.tsx" + ); + + createPage({ + path: "/search/", + component: template, + context: { + feature: { + banner: false, + }, + }, + }); +}; diff --git a/gatsby/create-pages/index.ts b/gatsby/create-pages/index.ts new file mode 100644 index 00000000..2efeba8e --- /dev/null +++ b/gatsby/create-pages/index.ts @@ -0,0 +1,5 @@ +export { createDocHome } from "./create-doc-home"; +export { createDocs } from "./create-docs"; +export { createCloudAPIReference } from "./create-cloud-api"; +export { createDocSearch } from "./create-search"; +export { create404 } from "./create-404"; diff --git a/gatsby/create-pages/interface.ts b/gatsby/create-pages/interface.ts new file mode 100644 index 00000000..a87d2723 --- /dev/null +++ b/gatsby/create-pages/interface.ts @@ -0,0 +1,13 @@ +import { BuildType } from "../../src/shared/interface"; + +export const DEFAULT_BUILD_TYPE: BuildType = "prod"; + +export interface PageQueryData { + allMdx: { + nodes: { + id: string; + frontmatter: { aliases: string[] }; + slug: string; + }[]; + }; +} diff --git a/gatsby/path.ts b/gatsby/path.ts index 384c2254..44a223b0 100644 --- a/gatsby/path.ts +++ b/gatsby/path.ts @@ -1,4 +1,4 @@ -import { Locale, Repo, PathConfig } from "../src/shared/interface"; +import { Locale, Repo, PathConfig, CloudPlan } from "../src/shared/interface"; import CONFIG from "../docs/docs.json"; export function generateUrl(filename: string, config: PathConfig) { @@ -56,17 +56,17 @@ export function generateConfig(slug: string): { let name = rest[rest.length - 1]; name = name === "_index" ? "" : name; - let prefix = undefined; + let prefix: CloudPlan | undefined = undefined; if (repo === Repo.tidbcloud) { - if (slug.includes("starter/")) { - prefix = "starter"; - } else if (slug.includes("essential/")) { - prefix = "essential"; - } else if (slug.includes("dedicated/")) { - if (!!name) { - prefix = "dedicated"; - } + const simplePrefixes = ["starter", "essential", "premium"]; + prefix = simplePrefixes.find((p) => slug.includes(`${p}/`)) as + | CloudPlan + | undefined; + + // dedicated prefix is only used when the name is not empty + if (!prefix && slug.includes("dedicated/") && name) { + prefix = "dedicated"; } } diff --git a/gatsby/toc.ts b/gatsby/toc.ts index f037db07..bce566ca 100644 --- a/gatsby/toc.ts +++ b/gatsby/toc.ts @@ -9,10 +9,20 @@ import { Heading, } from "mdast"; -import { RepoNav, RepoNavLink, PathConfig } from "../src/shared/interface"; +import { + RepoNav, + RepoNavLink, + PathConfig, + CloudPlan, +} from "../src/shared/interface"; import { generateUrl } from "./path"; -export const EXTENDS_FOLDERS = ["starter", "essential", "dedicated"]; +export const EXTENDS_FOLDERS: CloudPlan[] = [ + "starter", + "essential", + "dedicated", + "premium", +]; const SKIP_MODE_HEADING = "_BUILD_ALLOWLIST"; diff --git a/src/components/MDXComponents/CustomContent.tsx b/src/components/MDXComponents/CustomContent.tsx index 9f2f1a3b..aefe6c8c 100644 --- a/src/components/MDXComponents/CustomContent.tsx +++ b/src/components/MDXComponents/CustomContent.tsx @@ -1,6 +1,6 @@ import { PropsWithChildren } from "react"; import { PageType } from "shared/utils"; -import { CloudPlan } from "shared/useCloudPlan"; +import { CloudPlan } from "shared/interface"; interface CustomContentProps { platform?: "tidb" | "tidb-cloud"; diff --git a/src/components/MDXContent.tsx b/src/components/MDXContent.tsx index 8b629b7e..615c03ba 100644 --- a/src/components/MDXContent.tsx +++ b/src/components/MDXContent.tsx @@ -8,13 +8,17 @@ import Box from "@mui/material/Box"; import * as MDXComponents from "components/MDXComponents"; import { CustomNotice } from "components/Card/CustomNotice"; -import { PathConfig, FrontMatter, BuildType } from "shared/interface"; +import { + PathConfig, + FrontMatter, + BuildType, + CloudPlan, +} from "shared/interface"; import { useTotalContributors } from "components/Contributors"; import replaceInternalHref from "shared/utils/anchor"; import { Pre } from "components/MDXComponents/Pre"; import { useCustomContent } from "components/MDXComponents/CustomContent"; import { getPageType } from "shared/utils"; -import { CloudPlan } from "shared/useCloudPlan"; export default function MDXContent(props: { data: any; diff --git a/src/shared/filterRightToc.ts b/src/shared/filterRightToc.ts index 59048afb..0b1e5754 100644 --- a/src/shared/filterRightToc.ts +++ b/src/shared/filterRightToc.ts @@ -1,6 +1,5 @@ -import { TableOfContent } from "./interface"; +import { TableOfContent, CloudPlan } from "./interface"; import { PageType } from "./utils"; -import { CloudPlan } from "./useCloudPlan"; /** * Filter right TOC based on CustomContent conditions diff --git a/src/shared/interface.ts b/src/shared/interface.ts index e7a8a314..97cd2b16 100644 --- a/src/shared/interface.ts +++ b/src/shared/interface.ts @@ -67,3 +67,5 @@ export interface RepoNavLink { export type RepoNav = RepoNavLink[]; export type BuildType = "prod" | "archive"; + +export type CloudPlan = "dedicated" | "starter" | "essential" | "premium"; diff --git a/src/shared/useCloudPlan.ts b/src/shared/useCloudPlan.ts index beac6547..34b0cdc4 100644 --- a/src/shared/useCloudPlan.ts +++ b/src/shared/useCloudPlan.ts @@ -7,15 +7,13 @@ import { useEffect, useState, } from "react"; -import { Repo } from "./interface"; +import { CloudPlan, Repo } from "./interface"; export const CLOUD_MODE_KEY = "plan"; export const CLOUD_MODE_VALUE_STARTER = "starter"; export const CLOUD_MODE_VALUE_ESSENTIAL = "essential"; export const CLOUD_MODE_VALUE_PREMIUM = "premium"; -export type CloudPlan = "dedicated" | "starter" | "essential" | "premium"; - const CloudPlanContext = createContext<{ repo: Repo; cloudPlan: CloudPlan | null; diff --git a/src/templates/DocTemplate.tsx b/src/templates/DocTemplate.tsx index 36767104..7fcfccaa 100644 --- a/src/templates/DocTemplate.tsx +++ b/src/templates/DocTemplate.tsx @@ -23,6 +23,7 @@ import { RepoNav, BuildType, Locale, + CloudPlan, } from "shared/interface"; import Seo from "components/Seo"; import { getStable, generateUrl, getPageType } from "shared/utils"; @@ -32,7 +33,6 @@ import { FeedbackSurveyCampaign } from "components/Campaign/FeedbackSurvey"; import { DOC_HOME_URL } from "shared/resources"; import { useReportReadingRate } from "shared/useReportReadingRate"; import { - CloudPlan, CloudPlanProvider, useCloudPlan, useCloudPlanNavigate,