-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(storybook): use semantic headings for better seo (#8027)
- Loading branch information
1 parent
1439370
commit 917dc61
Showing
4 changed files
with
36 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { addons } from '@storybook/manager-api'; | ||
import { CURRENT_STORY_WAS_SET } from '@storybook/core-events'; | ||
|
||
const ADDON_ID = 'title-enhancer'; | ||
|
||
addons.register(ADDON_ID, (api) => { | ||
const setTitle = () => { | ||
const storyData = api.getCurrentStoryData(); | ||
const getComponentTag = (title: string) => { | ||
const componentName = title.split('/').pop(); | ||
return `ui5-${componentName?.split(' ').join('-').toLowerCase()}`; | ||
} | ||
|
||
let keywords = ""; | ||
|
||
if (storyData?.tags?.includes('autodocs')) { | ||
// autodocs generated per component | ||
keywords = `${storyData.title} - ${getComponentTag(storyData.title)}`; | ||
} else if (storyData?.tags?.includes('story')) { | ||
// stories generated per component | ||
keywords = `${storyData.title} - ${getComponentTag(storyData.title)} - ${storyData.name}`; | ||
} else if (storyData?.tags?.includes('docs')) { | ||
// docs generated out of the md files | ||
keywords = `${storyData.title}`; | ||
} | ||
|
||
document.title = `${keywords} | UI5 Web Components | Documentation` | ||
}; | ||
|
||
api.on(CURRENT_STORY_WAS_SET, () => { | ||
setTitle(); | ||
}) | ||
}); |
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