From a0f8efc62721805e69b8ff2114965a080c86fe39 Mon Sep 17 00:00:00 2001 From: Yossi Saadi Date: Tue, 10 Sep 2024 09:41:53 +0300 Subject: [PATCH] docs: script to update storybook title to Vibe it loads with "@storybook/cli" title, we need to update it. inspired by PRs mentioned in Storybook's issue: https://github.com/storybookjs/storybook/issues/22211 --- .../core/.storybook/storybook-title-fix.js | 23 +++++++++++++++++++ packages/core/package.json | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/core/.storybook/storybook-title-fix.js diff --git a/packages/core/.storybook/storybook-title-fix.js b/packages/core/.storybook/storybook-title-fix.js new file mode 100644 index 0000000000..96e85562d3 --- /dev/null +++ b/packages/core/.storybook/storybook-title-fix.js @@ -0,0 +1,23 @@ +import { readFileSync, writeFileSync } from "fs"; +import { join } from "path"; + +function updateHtmlTitle(file, newTitle) { + const fileContents = readFileSync(file, "utf8"); + const modifiedContents = fileContents.replace(/.*<\/title>/, `<title>${newTitle}`); + writeFileSync(file, modifiedContents); +} + +function updateStorybookHtmlTitles(storybookDir) { + try { + if (!storybookDir) { + throw new Error("Please provide the path to the storybook directory."); + } + const newTitle = "Vibe Design System"; + ["index.html", "iframe.html"].forEach(filePath => updateHtmlTitle(join(storybookDir, filePath), newTitle)); + } catch (err) { + console.error(err); + process.exit(1); + } +} + +updateStorybookHtmlTitles(process.argv[2]); diff --git a/packages/core/package.json b/packages/core/package.json index f9a27ae254..e92c58b23a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -64,7 +64,7 @@ "build:esm:mock-classnames": "mock_classnames=on rollup -c", "build:react-icons": "svg2react-icon --typescript --keep-colors ../../node_modules/monday-ui-style/src/Icons src/components/Icon/Icons", "storybook": "storybook dev -p 7008", - "build-storybook": "storybook build -o static_storybook", + "build-storybook": "storybook build -o static_storybook && node .storybook/storybook-title-fix.js static_storybook", "deploy-storybook": "storybook-to-ghpages", "chromatic:local": "chromatic -t $CHROMATIC_PROJECT_TOKEN", "link-local": "npm link && npm start",