-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from contentstack/staging
Json Preview
- Loading branch information
Showing
30 changed files
with
2,782 additions
and
20,619 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
/* 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, | ||
node: true, | ||
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", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/* eslint-disable camelcase */ | ||
import React from "react"; | ||
|
||
export default function BlogBanner(props) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
import React from "react"; | ||
import Link from "next/link"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div | ||
className="modal fade" | ||
id="staticBackdrop" | ||
data-bs-backdrop="static" | ||
data-bs-keyboard="false" | ||
tabIndex="-1" | ||
aria-labelledby="staticBackdropLabel" | ||
aria-hidden="true" | ||
> | ||
<div className="modal-dialog modal-lg"> | ||
<div className="modal-content"> | ||
<div className="modal-header"> | ||
<h2 className="modal-title" id="staticBackdropLabel"> | ||
Json Response | ||
</h2> | ||
<button | ||
type="button" | ||
className="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="Close" | ||
/> | ||
</div> | ||
<div className="modal-body"> | ||
{response ? ( | ||
<pre id="jsonViewer"> | ||
{response && ( | ||
<DynamicReactJson | ||
src={filteredJson} | ||
collapsed={1} | ||
name="response" | ||
enableClipboard={false} | ||
/> | ||
)} | ||
</pre> | ||
) : ( | ||
"" | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default DevTools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
/* eslint-disable no-restricted-syntax */ | ||
/* eslint-disable no-unused-expressions */ | ||
import React from "react"; | ||
import Head from "next/head"; | ||
import Header from "./header"; | ||
import Footer from "./footer"; | ||
import DevTools from "./devtools"; | ||
|
||
class Layout extends React.Component { | ||
render() { | ||
const { | ||
header, footer, page, blogpost, children, | ||
} = this.props; | ||
|
||
const jsonObj = { header, footer }; | ||
page && (jsonObj.page = page); | ||
blogpost && (jsonObj.blog_post = blogpost); | ||
|
||
function metaData(seo) { | ||
const metaArr = []; | ||
for (const key in seo) { | ||
|
@@ -29,6 +38,24 @@ class Layout extends React.Component { | |
href="https://fonts.googleapis.com/css?family=Inter&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css" | ||
integrity="sha512-YWzhKL2whUzgiheMoBFwW8CKV4qpHQAEuvilg9FAn5VJUDwKZZxkJNuGM4XkWuk94WCrrwslk8yWNGmY1EduTA==" | ||
crossOrigin="anonymous" | ||
referrerPolicy="no-referrer" | ||
/> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" | ||
crossOrigin="anonymous" | ||
/> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" | ||
crossOrigin="anonymous" | ||
/> | ||
<meta | ||
name="application-name" | ||
content="Contentstack-Nextjs-Starter-App" | ||
|
@@ -44,13 +71,16 @@ class Layout extends React.Component { | |
<link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png" /> | ||
<meta name="theme-color" content="#317EFB" /> | ||
<title>Contentstack-Nextjs-Starter-App</title> | ||
{this.props.seo && this.props.seo.enable_search_indexing | ||
? metaData(this.props.seo) | ||
{page.seo && page.seo.enable_search_indexing | ||
? metaData(page.seo) | ||
: null} | ||
</Head> | ||
{this.props.header ? <Header header={this.props.header} /> : ""} | ||
<main className="mainClass">{this.props.children}</main> | ||
{this.props.footer ? <Footer footer={this.props.footer} /> : ""} | ||
{header ? <Header header={header} /> : ""} | ||
<main className="mainClass"> | ||
{children} | ||
{Object.keys(jsonObj).length && <DevTools response={jsonObj} />} | ||
</main> | ||
{footer ? <Footer footer={footer} /> : ""} | ||
</> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.