-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce new
create-new-microsite
script and update site template (#…
…2088) * feat: introduce new create-microsite script + update site template * fix: build issue * fix: markdown-components file * chore: remove markdown components from site template * chore: improve shell script logs * chore: remove markdown components file * chore: add missing files * chore: empty commit * refactor: use correct eslint config * chore: keep changelog * chore: add comments * chore: check in addon-components * refactor: adjust documentation / gitignore / changelog
- Loading branch information
Showing
19 changed files
with
230 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
packages/gatsby-theme-docs/src/overrides/page-header-banner-area.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import React from 'react'; | ||
import UserResearchBanner from '../components/user-research-banner'; | ||
|
||
// A banner to be rendered in the top-right corner of a content page | ||
const PageHeaderBannerArea = () => { | ||
return <UserResearchBanner />; | ||
}; | ||
const PageHeaderBannerArea = () => null; | ||
export default PageHeaderBannerArea; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const prompts = require('prompts'); | ||
|
||
(async () => { | ||
const response = await prompts({ | ||
type: 'text', | ||
name: 'micrositeName', | ||
message: 'What is the name of the new microsite?', | ||
validate: (micrositeName) => | ||
micrositeName.length > 64 ? `Microsite name is too long.` : true, | ||
}); | ||
|
||
const formattedMicrositeName = response.micrositeName | ||
.replace(/\s+/g, '-') | ||
.toLowerCase(); | ||
const micrositeTitle = | ||
response.micrositeName.replace(/-/g, ' ').charAt(0).toUpperCase() + | ||
response.micrositeName.slice(1); | ||
|
||
const gatsbyConfigTemplate = `import { configureThemeWithAddOns } from '@commercetools-docs/gatsby-theme-docs/configure-theme.mjs'; | ||
const isProd = process.env.NODE_ENV === 'production'; | ||
const shouldEnableSearch = process.env.ENABLE_SEARCH === 'true'; | ||
const config = { | ||
flags: { | ||
FAST_DEV: true, | ||
}, | ||
pathPrefix: '/${formattedMicrositeName}', | ||
siteMetadata: { | ||
title: '${micrositeTitle}', | ||
description: 'CHANGE DESCRIPTION HERE', | ||
products: ['smokeTest'], | ||
contentType: 'test', | ||
breadcrumbs: '', | ||
betaLink: '/beta', | ||
excludeFromSearchIndex: isProd && !shouldEnableSearch, | ||
}, | ||
plugins: [ | ||
...configureThemeWithAddOns({ | ||
websiteKey: '${formattedMicrositeName}', | ||
auth0Domain: 'auth.id.commercetools.com', | ||
auth0ClientId: 'xLk8EDUCc8PKqCbrSJCnuahvn86nEn4z', | ||
selfLearningFeatures: ['complete-profile-modal'], | ||
hideLogin: true, | ||
aiAssistantTopbarButton: true, | ||
aiAssistantApiBaseUrl: 'https://assistant-api.commercetools.vercel.app', | ||
learnApiBaseUrl: | ||
isProd === 'true' | ||
? 'https://learning-api.docs.commercetools.com' | ||
: 'https://learning-api.commercetools.vercel.app', | ||
additionalPrismLanguages: [ | ||
'markup-templating', | ||
'json', | ||
'bash', | ||
'java', | ||
'scala', | ||
'csharp', | ||
'swift', | ||
'php', | ||
], | ||
}), | ||
], | ||
}; | ||
export default config; | ||
`; | ||
|
||
const websitesFolderPath = `${process.cwd()}/websites`; | ||
|
||
// Using the site template to create the new microsite folder | ||
fs.cpSync( | ||
`${websitesFolderPath}/site-template`, | ||
`${websitesFolderPath}/${formattedMicrositeName}`, | ||
{ recursive: true } | ||
); | ||
|
||
// Overriding the gatsby config with the given microsite name | ||
fs.writeFileSync( | ||
`${websitesFolderPath}/${formattedMicrositeName}/gatsby-config.mjs`, | ||
gatsbyConfigTemplate | ||
); | ||
|
||
// Overriding the package.json file with the given microsite name | ||
const packageJson = JSON.parse( | ||
fs.readFileSync( | ||
`${websitesFolderPath}/${formattedMicrositeName}/package.json` | ||
) | ||
); | ||
packageJson.name = `@commercetools-website/${formattedMicrositeName}`; | ||
fs.writeFileSync( | ||
`${websitesFolderPath}/${formattedMicrositeName}/package.json`, | ||
JSON.stringify(packageJson) | ||
); | ||
|
||
// Creating a fresh CHANGELOG | ||
fs.writeFileSync( | ||
`${websitesFolderPath}/${formattedMicrositeName}/CHANGELOG.md`, | ||
'' | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "Starting the process." | ||
|
||
yarn node ./scripts/create-new-microsite.js | ||
|
||
echo "New microsite created." | ||
echo "Installing dependencies." | ||
|
||
yarn | ||
|
||
echo "Process complete." | ||
Purple='\033[0;35m' | ||
echo -e "${Purple}Please add the new microsite to the build.sh script in the root folder to enable production builds." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ocs-smoke-test/src/@commercetools-docs/gatsby-theme-docs/overrides/markdown-components.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
websites/site-template/src/@commercetools-docs/gatsby-theme-docs/overrides/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addon-components.js |
Oops, something went wrong.