diff --git a/env.sample b/.env.sample similarity index 100% rename from env.sample rename to .env.sample diff --git a/.eslintrc.js b/.eslintrc.js index aa729de..3225e7a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,17 +1,16 @@ -/* eslint-disable prettier/prettier */ module.exports = { - parser: 'babel-eslint', + parser: "babel-eslint", parserOptions: { ecmaVersion: 6, - sourceType: 'module', + sourceType: "module", ecmaFeatures: { jsx: true, modules: true, experimentalObjectRestSpread: true, }, }, - extends: ['plugin:prettier/recommended', 'airbnb'], - plugins: ['react', 'jsx-a11y', 'import', 'prettier'], + extends: ["plugin:prettier/recommended", "airbnb"], + plugins: ["react", "jsx-a11y", "import", "prettier"], env: { es6: true, browser: true, @@ -19,14 +18,24 @@ module.exports = { jest: true, }, rules: { - 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], - "react/prefer-stateless-function":[0, { "ignorePureComponents": true }], + "react/jsx-filename-extension": [1, { extensions: [".js", ".jsx"] }], + "react/prefer-stateless-function": [0, { ignorePureComponents: true }], "react/prop-types": [0], - 'func-names': ['error', 'never'], - quotes: 'off', - 'prettier/prettier': 'off', - 'prop-types': 'off', - 'react/destructuring-assignment': 'off', - 'eslint-disable-next-line jsx-a11y/anchor-is-valid':'off', + "func-names": ["error", "never"], + quotes: "off", + "prop-types": "off", + "no-continue": "off", + "guard-for-in": "off", + "global-require": "off", + "no-param-reassign": "off", + "prettier/prettier": "off", + "consistent-return": "off", + "no-unused-expressions": "off", + "no-restricted-syntax": "off", + "react/no-array-index-key": "off", + "jsx-a11y/anchor-is-valid": "off", + "react/destructuring-assignment": "off", + "jsx-a11y/label-has-associated-control": "off", + "eslint-disable-next-line jsx-a11y/anchor-is-valid": "off", }, }; diff --git a/README.md b/README.md index 06f9c25..28e45f2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Contentstack](https://camo.githubusercontent.com/d24f513afa94a4a762533d54a0f590300dbd0413/68747470733a2f2f7777772e636f6e74656e74737461636b2e636f6d2f646f63732f7374617469632f696d616765732f636f6e74656e74737461636b2e706e67)](https://www.contentstack.com/) +[![Contentstack Logo](/public/contentstack-readme-logo.png)](https://www.contentstack.com/) # Build a Starter Website with Next.js and Contentstack diff --git a/components/about-section-bucket.js b/components/about-section-bucket.js index 3b9f82e..8744fb2 100644 --- a/components/about-section-bucket.js +++ b/components/about-section-bucket.js @@ -1,6 +1,5 @@ -/* eslint-disable no-undef */ import React from "react"; -import ReactHtmlParser from "react-html-parser"; +import parse from "html-react-parser"; export default function AboutSectionBucket(props) { const { sectionWithBuckets } = props; @@ -13,7 +12,7 @@ export default function AboutSectionBucket(props) {
{bucket.title_h3 &&

{bucket.title_h3}

} - {bucket.description && ReactHtmlParser(bucket.description)} + {bucket.description && parse(bucket.description)}
); diff --git a/components/archive-relative.js b/components/archive-relative.js index 352409f..979fd72 100644 --- a/components/archive-relative.js +++ b/components/archive-relative.js @@ -1,7 +1,6 @@ -/* eslint-disable jsx-a11y/anchor-is-valid */ import React from "react"; import Link from "next/link"; -import ReactHtmlParser from "react-html-parser"; +import parse from "html-react-parser"; export default function ArchiveRelative(props) { const { blogs } = props; @@ -12,7 +11,7 @@ export default function ArchiveRelative(props) {

{blog.title}

- {ReactHtmlParser(blog.body.slice(0, 80))} + {parse(blog.body.slice(0, 80))}
diff --git a/components/blog-banner.js b/components/blog-banner.js index 121a9d6..0c3003a 100644 --- a/components/blog-banner.js +++ b/components/blog-banner.js @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ import React from "react"; export default function BlogBanner(props) { diff --git a/components/blog-section.js b/components/blog-section.js index 28c3010..d6ac4a0 100644 --- a/components/blog-section.js +++ b/components/blog-section.js @@ -1,11 +1,6 @@ -/* eslint-disable jsx-a11y/anchor-is-valid */ -/* eslint-disable react/prop-types */ -/* eslint-disable react/prefer-stateless-function */ -/* eslint-disable no-undef */ -/* eslint-disable react/no-array-index-key */ import React from "react"; import Link from "next/link"; -import ReactHtmlParser from "react-html-parser"; +import parse from "html-react-parser"; class BlogSection extends React.Component { render() { @@ -34,7 +29,7 @@ class BlogSection extends React.Component { )}
{blog.title &&

{blog.title}

} - {blog.body && ReactHtmlParser(blog.body.slice(0, 300))} + {blog.body && parse(blog.body.slice(0, 300))} {blog.url && ( {"Read More -->"} diff --git a/components/card-section.js b/components/card-section.js index 106518d..da10958 100644 --- a/components/card-section.js +++ b/components/card-section.js @@ -1,4 +1,3 @@ -/* eslint-disable jsx-a11y/anchor-is-valid */ import React from "react"; import Link from "next/link"; diff --git a/components/devtools.js b/components/devtools.js new file mode 100644 index 0000000..ee73b0d --- /dev/null +++ b/components/devtools.js @@ -0,0 +1,74 @@ +import React from "react"; +import dynamic from "next/dynamic"; + +const DynamicReactJson = dynamic(import("react-json-view"), { ssr: false }); + +function filterObject(inputObject) { + const unWantedProps = [ + "uid", + "_version", + "ACL", + "_in_progress", + "created_at", + "created_by", + "updated_at", + "updated_by", + "publish_details", + ]; + for (const key in inputObject) { + unWantedProps.includes(key) && delete inputObject[key]; + if (typeof inputObject[key] !== "object") { + continue; + } + inputObject[key] = filterObject(inputObject[key]); + } + return inputObject; +} + +const DevTools = ({ response }) => { + const filteredJson = filterObject(response); + return ( + + ); +}; +export default DevTools; diff --git a/components/footer.js b/components/footer.js index 5df7e6c..fe6bef9 100644 --- a/components/footer.js +++ b/components/footer.js @@ -1,7 +1,6 @@ -/* eslint-disable jsx-a11y/alt-text */ import React from "react"; import Link from "next/link"; -import ReactHtmlParser from "react-html-parser"; +import parse from "html-react-parser"; export default function Footer(props) { const { footer } = props; @@ -21,7 +20,7 @@ export default function Footer(props) {
- {footer.social.social_share?.map(social => ( + {footer.social.social_share?.map((social) => (
- {footer.copyright && ReactHtmlParser(footer.copyright)} + {footer.copyright && parse(footer.copyright)}
); diff --git a/components/header.js b/components/header.js index d483da1..3c973d3 100644 --- a/components/header.js +++ b/components/header.js @@ -1,23 +1,27 @@ -/* eslint-disable jsx-a11y/anchor-is-valid */ -/* eslint-disable jsx-a11y/label-has-associated-control */ -/* eslint-disable jsx-a11y/label-has-for */ import React from "react"; import Link from "next/link"; import { useRouter } from "next/router"; -import ReactHtmlParser from "react-html-parser"; +import parse from "html-react-parser"; export default function Header(props) { const { header } = props; const router = useRouter(); return (
- {header.notification_bar.show_announcement ? ( -
- {ReactHtmlParser(header.notification_bar.announcement_text)} -
- ) : ( - "" - )} +
+ {header.notification_bar.show_announcement ? ( + parse(header.notification_bar.announcement_text) + ) : ( +
Devtools section
+ )} + + dev tools icon + +
@@ -35,10 +39,18 @@ export default function Header(props) {