Skip to content

Commit 02c8873

Browse files
authored
Merge pull request #7 from contentstack/feat/ECO-184_added_json_rte
feat:replace RTE with JSON RTE [ECO-184]
2 parents b11e3f5 + 0879458 commit 02c8873

File tree

15 files changed

+134
-71
lines changed

15 files changed

+134
-71
lines changed

components/about-section-bucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function AboutSectionBucket(props) {
1212

1313
<div className="mission-section-content">
1414
{bucket.title_h3 && <h3>{bucket.title_h3}</h3>}
15-
{bucket.description && parse(bucket.description)}
15+
{typeof bucket.description === "string" && parse(bucket.description)}
1616
</div>
1717
</div>
1818
);

components/archive-relative.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function ArchiveRelative(props) {
1111
<a>
1212
<div>
1313
<h4>{blog.title}</h4>
14-
{parse(blog.body.slice(0, 80))}
14+
{typeof blog.body === "string" && parse(blog.body.slice(0, 80))}
1515
</div>
1616
</a>
1717
</Link>

components/blog-section.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BlogSection extends React.Component {
2929
)}
3030
<div className="featured-content">
3131
{blog.title && <h3>{blog.title}</h3>}
32-
{blog.body && parse(blog.body.slice(0, 300))}
32+
{typeof blog.body === "string" && parse(blog.body.slice(0, 300))}
3333
{blog.url && (
3434
<Link href={blog.url} passHref>
3535
<a className="blogpost-readmore">{"Read More -->"}</a>

components/footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function Footer(props) {
4343
</div>
4444
</div>
4545
<div className="copyright">
46-
{footer.copyright && parse(footer.copyright)}
46+
{typeof footer.copyright === "string" && parse(footer.copyright)}
4747
</div>
4848
</footer>
4949
);

components/header.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ export default function Header(props) {
99
return (
1010
<header className="header">
1111
<div className="note-div">
12-
{header.notification_bar.show_announcement ? (
13-
parse(header.notification_bar.announcement_text)
14-
) : (
12+
{header.notification_bar.show_announcement ? typeof header.notification_bar.announcement_text === "string"
13+
&& (
14+
parse(header.notification_bar.announcement_text)
15+
) : (
1516
<div style={{ visibility: "hidden" }}>Devtools section</div>
1617
)}
1718
<span

components/section-bucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SectionBucket extends React.Component {
1717
{bucket.icon && <img src={bucket.icon.url} alt="bucket icon" />}
1818

1919
{bucket.title_h3 ? <h3>{bucket.title_h3}</h3> : ""}
20-
{bucket.description && parse(bucket.description)}
20+
{typeof bucket.description === "string" && parse(bucket.description)}
2121
{bucket.call_to_action.title ? (
2222
<Link
2323
href={

components/section-with-html-code.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export default function SectionWithHtmlCode(props) {
77
<div className="contact-page-section max-width">
88
<div className="contact-page-content">
99
{embedCode.title && <h1>{embedCode.title}</h1>}
10-
{embedCode.description && parse(embedCode.description)}
10+
{typeof embedCode.description === "string" && parse(embedCode.description)}
1111
</div>
1212
<div className="contact-page-form">
13-
{embedCode.html_code
13+
{typeof embedCode.html_code === "string"
1414
&& parse(embedCode.html_code)}
1515
</div>
1616
</div>
@@ -19,15 +19,15 @@ export default function SectionWithHtmlCode(props) {
1919
return (
2020
<div className="contact-maps-section max-width">
2121
<div className="maps-details">
22-
{parse(embedCode.html_code)}
22+
{typeof embedCode.html_code === "string" && parse(embedCode.html_code)}
2323
</div>
2424
<div className="contact-maps-content">
2525
{embedCode.title ? (
2626
<h2>{embedCode.title}</h2>
2727
) : (
2828
""
2929
)}
30-
{embedCode.description && parse(embedCode.description)}
30+
{typeof embedCode.description === "string" && parse(embedCode.description)}
3131
</div>
3232
</div>
3333
);

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "contentstack-nextjs-starter-app",
33
"description": "A starter app for Contentstack and Nextjs",
4-
"version": "1.1.1",
4+
"version": "1.2.0",
55
"private": true,
66
"author": "Contentstack",
77
"scripts": {

pages/about-us.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ export default function About(props) {
2222

2323
export async function getServerSideProps(context) {
2424
try {
25-
const result = await Stack.getEntryByUrl("page", context.resolvedUrl);
26-
const header = await Stack.getEntry(
27-
"header",
28-
"navigation_menu.page_reference",
29-
);
30-
const footer = await Stack.getEntry("footer");
25+
const result = await Stack.getEntryByUrl({
26+
contentTypeUid: "page",
27+
entryUrl: context.resolvedUrl,
28+
jsonRtePath: ["page_components.section_with_buckets.buckets.description"],
29+
});
30+
const header = await Stack.getEntry({
31+
contentTypeUid: "header",
32+
referenceFieldPath: ["navigation_menu.page_reference"],
33+
jsonRtePath: ["notification_bar.announcement_text"],
34+
});
35+
const footer = await Stack.getEntry({
36+
contentTypeUid: "footer",
37+
jsonRtePath: ["copyright"],
38+
});
3139
return {
3240
props: {
3341
header: header[0][0],

0 commit comments

Comments
 (0)