Skip to content

Commit

Permalink
docs: script to update storybook title to Vibe
Browse files Browse the repository at this point in the history
it loads with "@storybook/cli" title, we need to update it. inspired by PRs mentioned in Storybook's issue: storybookjs/storybook#22211
  • Loading branch information
YossiSaadi committed Sep 23, 2024
1 parent d863f34 commit a0f8efc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/core/.storybook/storybook-title-fix.js
Original file line number Diff line number Diff line change
@@ -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>/, `<title>${newTitle}</title>`);
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]);
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a0f8efc

Please sign in to comment.