-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to set the main document title #812
Comments
Comment by afc163 +1 |
Comment by TheSisb +1 |
Comment by bluetidepro +1 |
Comment by vgpena +1 |
Comment by ndelangen Should be fairly simple to implement, PR welcome! |
+1 |
+1 |
It feels like something simple to do right? Has anyone tried to implement this? Would any of you be interested in giving this a try? @philcockfield @fraedom-jmcmonagle @vgpena @bluetidepro @TheSisb @afc163 ? |
This is a simple hack for changing page title, name of the app in heading and favicon. Create 'manager-head.html' in .storybook/ folder with following content:
|
no worries, we added the If you're changing the name storybook, you can do this via the addon-options |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks! |
Strictly speaking this is fixed, we will implement #866 which I think will be what 99% of users want. |
'overwritten by Storybook' solution: // .storybook/manager.js
import './titleAddon'; // .storybook/titleAddon.js
import addons from '@storybook/addons'
import { STORY_RENDERED } from '@storybook/core-events'
addons.register('TitleAddon', api => {
const cunstomTitle = 'abc'; // Define your customTitle title
let interval = null;
const setTitle = () => {
clearTimeout(interval);
let storyData = null;
try {
storyData = api.getCurrentStoryData(); // Some time get error
} catch(e) {}
let title;
if (!storyData) {
title = cunstomTitle;
} else {
title = `${storyData.kind} - ${storyData.name} ⋅ ${cunstomTitle}`
}
if (document.title !== title) { // As few dom operations as possible
document.title = title;
}
interval = setTimeout(setTitle, 100);
};
setTitle();
api.on(STORY_RENDERED, story => {
setTitle();
})
}); |
#866 isn't quite what this issue is about. Also, it's still open as well. :( |
why don't open title custom? |
This is one without import { STORY_RENDERED, STORY_CHANGED, STORY_SPECIFIED } from '@storybook/core-events'
// .storybook/titleAddon.js
addons.register('TitleAddon', api => {
const customTitle = 'JujiDocs'; // Define your customTitle title
const setTitle = () => {
let storyData = null;
try {
// @ts-ignore
storyData = api.getCurrentStoryData(); // Some time get error
} catch(e) {}
// @ts-ignore
let title = storyData && storyData.title ?
// @ts-ignore
`${storyData.title} ⋅ ${customTitle}` :
customTitle
if (document.title !== title) { // As few dom operations as possible
document.title = title;
}
};
setTitle();
api.on(STORY_RENDERED, story => { setTitle(); })
api.on(STORY_CHANGED, story => { setTitle(); })
api.on(STORY_SPECIFIED, story => { setTitle(); })
}); Thank you @chvin for the example |
Issue by mnmtanish
Friday Oct 28, 2016 at 05:39 GMT
Originally opened as storybook-eol/storybook-addon-options#7
Related issue: #581
Add an option to set the storybook-ui page title.
The text was updated successfully, but these errors were encountered: