Skip to content
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

Fix: Use section title for isolation mode if component is not available (#965) #966

Merged
merged 2 commits into from
May 8, 2018

Conversation

mr-winter
Copy link
Contributor

Fixes issue #965 returning the section title, if no components are associated to the section that gets passed into the getPateTitle method.

The issue occurs when writing documentation in markdown with examples that don't directly relate to any component, such as typographic guidelines or colour patches.

Copy link
Member

@sapegin sapegin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One tiny note.

@@ -13,6 +13,10 @@ import { DisplayModes } from '../consts';
*/
export default function getPageTitle(sections, baseTitle, displayMode) {
if (displayMode === DisplayModes.component || displayMode === DisplayModes.example) {
if (!sections[0].components || !sections[0].components.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this would be much more readable:

// import get from 'lodash/get';
const name = get(sections[0], 'components.0.name', sections[0].name);
return `${name}${baseTitle}`;

@codecov-io
Copy link

codecov-io commented May 6, 2018

Codecov Report

Merging #966 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted Files Coverage Δ
src/utils/getPageTitle.js 100% <100%> (ø) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants