Skip to content

Commit

Permalink
docs(styleguide): fix configuration (#5523)
Browse files Browse the repository at this point in the history
* fix(styleguide): use custom SectionRenderer

Почему-то собственная обёртка не использовался, а бралась из
либы `@rsg-components/*`.

* feat(styleguide): add contentTitle prop to section

`contentTitle` полезен когда необходимо добавить в заголовок
страницы дополнительную мета инфоррмацию. Например,
добавить префикс перед `title`.
  • Loading branch information
inomdzhon authored Jul 26, 2023
1 parent e0a424d commit 29c5b59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 14 additions & 3 deletions styleguide/Components/Section/SectionRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ import SectionHeading from '@rsg-components/SectionHeading';
import PropTypes from 'prop-types';

export const SectionRenderer = (allProps) => {
const { title, name, slug, content, components, sections, depth, description, pagePerSection } =
allProps;
const {
title,
name,
slug,
content,
contentTitle,
components,
sections,
depth,
description,
pagePerSection,
} = allProps;

return (
<section data-testid={`section-${slug}`}>
Expand All @@ -17,7 +27,7 @@ export const SectionRenderer = (allProps) => {
pagePerSection={pagePerSection}
slotProps={allProps}
>
{title || name}
{contentTitle || title || name}
</SectionHeading>
)}
{description && <Markdown text={description} />}
Expand All @@ -33,6 +43,7 @@ SectionRenderer.propTypes = {
description: PropTypes.string,
slug: PropTypes.string.isRequired,
content: PropTypes.node,
contentTitle: PropTypes.string,
components: PropTypes.node,
sections: PropTypes.node,
isolated: PropTypes.bool,
Expand Down
4 changes: 3 additions & 1 deletion styleguide/Components/Section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import Components from '@rsg-components/Components';
import { useStyleGuideContext } from '@rsg-components/Context';
import Examples from '@rsg-components/Examples';
import SectionRenderer from '@rsg-components/Section/SectionRenderer';
import Sections from '@rsg-components/Sections';
import PropTypes from 'prop-types';
import SectionRenderer from './SectionRenderer';

const Section = ({ section, depth }) => {
const {
Expand All @@ -15,6 +15,7 @@ const Section = ({ section, depth }) => {
slug,
filepath,
content,
contentTitle,
components,
sections,
description,
Expand Down Expand Up @@ -46,6 +47,7 @@ const Section = ({ section, depth }) => {
slug={slug}
filepath={filepath}
content={contentJsx}
contentTitle={contentTitle}
components={componentsJsx}
sections={sectionsJsx}
depth={depth}
Expand Down

0 comments on commit 29c5b59

Please sign in to comment.