Skip to content

Commit a468ab2

Browse files
authored
feat: add support for premium slug in generateConfig function (#647)
* feat: add support for premium slug in generateConfig function - Introduced a new condition to handle slugs that include "premium/", allowing for better categorization in the configuration generation process. * refactor: update CloudPlan import paths across components - Replaced imports of CloudPlan from "shared/useCloudPlan" to "shared/interface" for consistency and clarity. - Adjusted related components to ensure proper usage of the updated CloudPlan type definition. * feat: extend EXTENDS_FOLDERS to include premium plan - Updated the EXTENDS_FOLDERS constant to include "premium" as a valid CloudPlan option, enhancing the flexibility of the table of contents generation. - Adjusted the type definition to ensure consistency with the new CloudPlan import. * feat: add CloudPlan type to path.ts for enhanced configuration - Imported CloudPlan into path.ts to support additional configuration options. - Updated the prefix variable type to CloudPlan | undefined for improved type safety in the generateConfig function. * feat: restructure page creation logic by modularizing create-pages functionality - Removed the existing create-pages.ts file and replaced it with modular files for creating specific pages: create-docs, create-doc-home, create-cloud-api, create-search, and create-404. - Introduced an interface file to define common types and constants, enhancing code organization and maintainability. - Each new file encapsulates the logic for creating its respective page, improving clarity and separation of concerns in the page generation process. * refactor: simplify prefix determination in generateConfig function - Replaced multiple conditional checks for slug prefixes with a more concise approach using an array and the find method. - Maintained the existing logic for handling the dedicated prefix based on the presence of a name, improving code readability and maintainability. * fix: update template import paths in page creation files - Adjusted the import paths for template files in create-404, create-cloud-api, create-doc-home, create-docs, and create-search to ensure correct resolution. - Enhanced consistency across page creation logic by standardizing the path structure.
1 parent 504fe1f commit a468ab2

File tree

17 files changed

+435
-388
lines changed

17 files changed

+435
-388
lines changed

gatsby/cloud-plan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mdxAstToToc, TocQueryData } from "./toc";
22
import { generateConfig } from "./path";
33
import { extractFilesFromToc } from "./toc-filter";
4-
import { CloudPlan } from "shared/useCloudPlan";
4+
import { CloudPlan } from "shared/interface";
55

66
type TocMap = Map<
77
string,

gatsby/create-pages.ts

Lines changed: 0 additions & 366 deletions
This file was deleted.

gatsby/create-pages/create-404.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { resolve } from "path";
2+
import type { CreatePagesArgs } from "gatsby";
3+
import { DEFAULT_BUILD_TYPE } from "./interface";
4+
import { BuildType } from "../../src/shared/interface";
5+
6+
export const create404 = async ({
7+
actions: { createPage },
8+
}: CreatePagesArgs) => {
9+
const template = resolve(__dirname, "../../src/templates/404Template.tsx");
10+
11+
createPage({
12+
path: "/404/",
13+
component: template,
14+
context: {
15+
buildType: (process.env.WEBSITE_BUILD_TYPE ??
16+
DEFAULT_BUILD_TYPE) as BuildType,
17+
feature: {
18+
banner: false,
19+
},
20+
},
21+
});
22+
};

0 commit comments

Comments
 (0)