Skip to content

chore(SDK): update SDK README.md Documentation #32192

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

Merged
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fc790db
chore(SDK UVE): Update README.md to reflect SDK changes and improve d…
rjvelazco May 16, 2025
c2c8874
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco May 20, 2025
1c2748a
chore(UVE SDK): update README.md
rjvelazco May 20, 2025
758e02d
chore(UVE SDK): update README.md v2
rjvelazco May 20, 2025
5db7d93
chore(UVE SDK): update README.md v3
rjvelazco May 20, 2025
12fbf84
chore(REACT SDK): update README.md
rjvelazco May 20, 2025
91fd606
chore(REACT SDK): update README.md v2
rjvelazco May 20, 2025
5dd6953
chore(REACT SDK): update README.md v3
rjvelazco May 20, 2025
7c83b21
chore(REACT SDK): update README.md v4
rjvelazco May 20, 2025
27a6e5e
chore(REACT SDK): update README.md v5
rjvelazco May 20, 2025
d757b5a
chore(REACT SDK): update README.md v6
rjvelazco May 20, 2025
e6179da
chore(REACT SDK): update README.md v7
rjvelazco May 20, 2025
c4ac163
chore(REACT SDK): update README.md v8
rjvelazco May 20, 2025
1368ed1
chore(CLIENT SDK): update README.md
rjvelazco May 20, 2025
8f96005
chore(CLIENT SDK): update README.md v1
rjvelazco May 20, 2025
ce349b5
chore(CLIENT SDK): update README.md v2
rjvelazco May 20, 2025
5d8eb6f
chore(CLIENT SDK): update README.md v3
rjvelazco May 20, 2025
fd29e11
chore(CLIENT SDK): update README.md v4
rjvelazco May 20, 2025
a87d843
chore(REACT SDK): update README.md v9
rjvelazco May 21, 2025
de32888
chore(REACT SDK): stable readme.md version
rjvelazco May 21, 2025
04de6ea
chore(UVE SDK): stable readme.md version
rjvelazco May 21, 2025
237839c
chore(ANGULAR SDK): stable readme.md version
rjvelazco May 22, 2025
0c3499d
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco May 22, 2025
da7dc67
chore(Client SDK): stable readme.md version
rjvelazco May 22, 2025
6091e16
feedback v1
rjvelazco May 22, 2025
936f51b
feedback v2
rjvelazco May 22, 2025
406749c
clean up
rjvelazco May 22, 2025
13ad41e
chore(types SDK): add README.md
rjvelazco May 22, 2025
1d16ce1
chore: Cleanup and Polish Client
rjvelazco May 23, 2025
c3ef2ef
Freddy's feedback v1
rjvelazco May 26, 2025
8605729
Freddy's feedback v2
rjvelazco May 26, 2025
d7c6d50
fix: Correct typos and formatting in Angular and React SDK README files
rjvelazco May 26, 2025
b6a4a04
refactor(README): Revise content for clarity, enhance structure, and …
rjvelazco May 26, 2025
81dbf28
chore(README): Remove unnecessary separators and streamline content i…
rjvelazco May 26, 2025
4711dbf
docs(README): Enhance UVE SDK documentation with detailed API referen…
rjvelazco May 26, 2025
5e502e1
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco May 26, 2025
9ed5900
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco May 27, 2025
1e3e159
docs(README): Angular and React README.md feedback
rjvelazco May 28, 2025
4ee5049
docs(README): Update dotCMS Client SDK README.md v1
rjvelazco May 28, 2025
7eeb979
docs(README): Update dotCMS Client SDK README.md v2
rjvelazco May 29, 2025
a8d9768
docs(README): Add section on enabling page editing in dotCMS with UVE…
rjvelazco May 29, 2025
16f2e9c
docs: clean up
rjvelazco May 30, 2025
5b68797
docs(README): add a Before You Use `@dotcms/uve` section
rjvelazco May 30, 2025
21d3687
docs(README): Update SDK documentation to standardize terminology and…
rjvelazco May 30, 2025
cc268f9
docs(README): cleanup
rjvelazco May 30, 2025
05894fd
docs(README): update SDK examples to use simplified query methods and…
rjvelazco May 30, 2025
c1a6688
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco Jun 2, 2025
53aa086
docs(README): enhance SDK documentation with new image processing lin…
rjvelazco Jun 3, 2025
a8d05b9
docs(README): expand SDK documentation with detailed type hierarchy a…
rjvelazco Jun 3, 2025
837b8e7
docs(README): add section on using dotCMS images with Angular’s NgOpt…
rjvelazco Jun 3, 2025
b84f6fc
Merge branch 'main' into issue-29560-sdk-update-readmemd-examples-doc…
rjvelazco Jun 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(REACT SDK): update README.md v5
  • Loading branch information
rjvelazco committed May 20, 2025
commit 27a6e5e7d342bd73c91e4e0e39fb73a45cf43024
119 changes: 118 additions & 1 deletion core-web/libs/sdk/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,41 @@ The `DotCMSLayoutBody` component renders the layout body for a DotCMS page. It u

> **Note:** Using `'development'` mode enhances troubleshooting by showing missing components and empty containers in your page. This helps identify issues with page composition. When your page is opened in the dotCMS editor, the development mode is automatically applied regardless of what you've explicitly set.

##### Usage
##### Implementation Details

The `DotCMSLayoutBody` component works by parsing the dotCMS page asset structure, which contains:

- **Layout information**: Rows, columns, and their sizing/positioning
- **Container references**: Identifiers that link to content containers
- **Content mapping**: How containers map to actual content

The component renders the page in this order:
1. Parses the layout body from the page asset
2. Renders each row in the layout
3. Renders columns within each row according to specified widths
4. Identifies containers within each column
5. Maps content from the page's contentlets to these containers
6. Renders each content item using the appropriate component from your `components` prop

When a container has no matching component for a content type, the component will:
- In `development` mode: Show a warning message with the missing content type
- In `production` mode: Silently skip rendering that content

##### Integration with dotCMS Page Editor

When used with the dotCMS Universal Visual Editor (UVE):

1. The component automatically detects when it's being rendered inside the editor
2. It adds necessary markup for the editor to identify editable regions
3. When content is edited in the UVE, changes are reflected in real-time
4. The editor can rearrange the layout structure, and the component will adapt accordingly

For this integration to work correctly, make sure to:
- Use the `useEditableDotCMSPage` hook to make the page editable
- Register all content types used in your page in the `components` prop
- Avoid manually modifying the layout structure received from the API

##### Basic Usage

```jsx
import { DotCMSLayoutBody } from '@dotcms/react/next';
Expand All @@ -128,6 +162,89 @@ const MyPage = ({ pageData }) => {
export default MyPage;
```

##### Common Pitfalls and Limitations

1. **Missing Content Type Components**
- If your `components` object doesn't have a mapping for a content type used in the page, that content won't render.
- Always ensure all content types used in your pages have corresponding components registered.

2. **Layout Structure Modifications**
- Modifying the layout structure directly may break the editor's ability to track changes.
- Always use the layout data as provided by the API without structural modifications.

3. **Performance Considerations**
- For pages with many content items, consider implementing component lazy loading.
- Avoid expensive operations in content type components as they may render multiple times.

4. **Sidebar Rendering**
- The sidebar content requires special handling if using custom grid systems.
- Sidebar location ('left', 'right') and width ('small', 'medium', 'large') should be translated to your CSS framework.

##### Advanced Usage

```jsx
import { useState, useEffect } from 'react';
import { DotCMSLayoutBody, useEditableDotCMSPage } from '@dotcms/react/next';
import { createDotCMSClient } from '@dotcms/client';

// Dynamically register components based on content type
const getComponents = () => {
// Core components
const baseComponents = {
'Blog': BlogComponent,
'Product': ProductComponent,
'Banner': BannerComponent
};

// Conditionally add components
if (process.env.FEATURE_EVENTS_ENABLED) {
return {
...baseComponents,
'CalendarEvent': EventComponent,
'EventRegistration': EventRegistrationComponent
};
}

return baseComponents;
};

// Custom wrapper component for specific content type
const ProductWithAnalytics = (props) => {
useEffect(() => {
// Track product impressions
analytics.trackImpression(props.identifier);
}, [props.identifier]);

return <ProductComponent {...props} />;
};

const MyAdvancedPage = ({ initialPageData }) => {
// Register components with special handling for certain content types
const [components] = useState(() => ({
...getComponents(),
// Override standard Product component with analytics-enhanced version
'Product': ProductWithAnalytics
}));

// Make the page editable with UVE
const editablePage = useEditableDotCMSPage(initialPageData);

return (
<div className="page-wrapper">
<DotCMSLayoutBody
page={editablePage.pageAsset}
components={components}
mode={process.env.NODE_ENV}
/>
</div>
);
};

export default MyAdvancedPage;
```

> **Note:** For a more detailed explanation of how to build React applications with dotCMS, see the [developer tutorial on using dotCMS with React](https://www.dotcms.com/blog/developer-tutorial-how-to-use-dotcms-and-react-to-build-single-page-apps).

#### `DotCMSShow`

The `DotCMSShow` component conditionally renders its children based on the Universal Visual Editor (UVE) mode. This is useful for displaying different content in different editing modes.
Expand Down