Skip to content

Commit

Permalink
[Layout][Next.js] Load the content styles for the RichText component …
Browse files Browse the repository at this point in the history
…(without using file proxy) (#1678)

* load content styles for rich text component

* fix linting errors

* update changelog

* fix linting error

* fix lint-samples step failing
  • Loading branch information
yavorsk authored and addy-pathania committed Dec 7, 2023
1 parent 48b2a9d commit f32eb12
Show file tree
Hide file tree
Showing 8 changed files with 467 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Our versioning strategy is as follows:
- Minor: may include breaking changes in framework packages (e.g. framework upgrades, new features, improvements)
- Major: may include breaking changes in core packages (e.g. major architectural changes, major features)

## Unreleased

### 🎉 New Features & Improvements

* `[sitecore-jss]` `[templates/nextjs]` Load the content styles for the RichText component [#1678](https://github.com/Sitecore/jss/pull/1678)

## 21.5.1

### 🐛 Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"typedoc-plugin-markdown": "^3.11.3",
"typescript": "~4.7.4"
},
"resolutions": {
"eslint-plugin-jsx-a11y": "6.7.1"
},
"workspaces": [
"packages/*",
"samples/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SitecorePageProps } from 'lib/page-props';
import { getContentStylesheetLink } from '@sitecore-jss/sitecore-jss-nextjs';
import { Plugin } from '..';

class ContentStylesPlugin implements Plugin {
order = 2;

async exec(props: SitecorePageProps) {
// Get content stylessheet link, empty if styles are not used on the page
const contentStyles = getContentStylesheetLink(props.layoutData);

contentStyles && props.headLinks.push(contentStyles);

return props;
}
}

export const contentStylesPlugin = new ContentStylesPlugin();
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export {
RenderingType,
EDITING_COMPONENT_PLACEHOLDER,
EDITING_COMPONENT_ID,
getContentStylesheetLink,
} from '@sitecore-jss/sitecore-jss/layout';
export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
export {
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
EditButtonTypes,
} from '@sitecore-jss/sitecore-jss/utils';
export {
getContentStylesheetLink,
LayoutService,
LayoutServiceData,
LayoutServicePageState,
Expand Down
Loading

0 comments on commit f32eb12

Please sign in to comment.