Skip to content
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

new academy code #22

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ CONTENTSTACK_DELIVERY_TOKEN=YOUR_DELIVERY_TOKEN
CONTENTSTACK_ENVIRONMENT=YOUR_PUBLISHING_ENVIRONMENT

# For live preview
CONTENTSTACK_MANAGEMENT_TOKEN=
CONTENTSTACK_API_HOST=api.contentstack.io
CONTENTSTACK_PREVIEW_TOKEN=
CONTENTSTACK_APP_HOST=app.contentstack.com
CONTENTSTACK_PREVIEW_HOST=rest-preview.contentstack.com
CONTENTSTACK_LIVE_PREVIEW=true
CONTENTSTACK_LIVE_EDIT_TAGS=true

Expand Down
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
11 changes: 0 additions & 11 deletions .github/workflows/sast-scan.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/secrets-scan.yml

This file was deleted.

2 changes: 1 addition & 1 deletion components/archive-relative.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ArchiveRelative({ blogs }: BlogListProps) {
return (
<>
{blogs?.map((blog, idx) => (
<Link href={blog.url} key={idx}>
<Link legacyBehavior href={blog.url} key={idx}>
<a>
<div>
<h4 {...blog.$?.title as {}}>{blog.title}</h4>
Expand Down
6 changes: 3 additions & 3 deletions components/blog-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function BlogList({ bloglist }: { bloglist: BloglistProps }) {
return (
<div className='blog-list'>
{bloglist.featured_image && (
<Link href={bloglist.url}>
<Link legacyBehavior href={bloglist.url}>
<a>
<img
className='blog-list-img'
Expand All @@ -50,7 +50,7 @@ function BlogList({ bloglist }: { bloglist: BloglistProps }) {
)}
<div className='blog-content'>
{bloglist.title && (
<Link href={bloglist.url}>
<Link legacyBehavior href={bloglist.url}>
<a>
<h3 {...bloglist.$?.title}>{bloglist.title}</h3>
</a>
Expand All @@ -67,7 +67,7 @@ function BlogList({ bloglist }: { bloglist: BloglistProps }) {
</p>
<div {...bloglist.$?.body as {}}>{parse(body)}</div>
{bloglist.url ? (
<Link href={bloglist.url}>
<Link legacyBehavior href={bloglist.url}>
<a>
<span>{'Read more -->'}</span>
</a>
Expand Down
4 changes: 2 additions & 2 deletions components/blog-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function BlogSection(props: FeaturedBlogProps) {
<h2 {...fromBlog.$?.title_h2 as {}}>{fromBlog.title_h2}</h2>
)}
{fromBlog.view_articles && (
<Link href={fromBlog.view_articles.href}>
<Link legacyBehavior href={fromBlog.view_articles.href}>
<a
className='btn secondary-btn article-btn'
{...fromBlog.view_articles.$?.title}
Expand All @@ -75,7 +75,7 @@ export default function BlogSection(props: FeaturedBlogProps) {
<div>{parse(blog.body.slice(0, 300))}</div>
)}
{blog.url && (
<Link href={blog.url} passHref>
<Link legacyBehavior href={blog.url} passHref>
<a className='blogpost-readmore'>{'Read More -->'}</a>
</Link>
)}
Expand Down
2 changes: 1 addition & 1 deletion components/card-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function CardSection({ cards }: CardProps) {
{card.description && <p {...card.$?.description as {}}>{card.description}</p>}
<div className='card-cta'>
{card.call_to_action.title && card.call_to_action.href && (
<Link href={card.call_to_action.href}>
<Link legacyBehavior href={card.call_to_action.href}>
<a className='btn primary-btn'>{card.call_to_action.title}</a>
</Link>
)}
Expand Down
224 changes: 112 additions & 112 deletions components/devtools.tsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,118 @@
import React, { useState, useEffect } from 'react';
import dynamic from 'next/dynamic';
import Tooltip from './tool-tip';
// import React, { useState, useEffect } from 'react';
// import dynamic from 'next/dynamic';
// import Tooltip from './tool-tip';

const DynamicReactJson = dynamic(import('react-json-view'), { ssr: false });
// const DynamicReactJson = dynamic(import('react-json-view'), { ssr: false });

function filterObject(inputObject: any) {
const unWantedProps = [
'_version',
'ACL',
'_owner',
'_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;
}
// function filterObject(inputObject: any) {
// const unWantedProps = [
// '_version',
// 'ACL',
// '_owner',
// '_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 }: any) => {
const filteredJson = filterObject(response);
const [forceUpdate, setForceUpdate] = useState(0);
// const DevTools = ({ response }: any) => {
// const filteredJson = filterObject(response);
// const [forceUpdate, setForceUpdate] = useState(0);

function copyObject(object: any) {
navigator.clipboard.writeText(object);
setForceUpdate(1);
}
// function copyObject(object: any) {
// navigator.clipboard.writeText(object);
// setForceUpdate(1);
// }

useEffect(() => {
if (forceUpdate !== 0) {
setTimeout(() => setForceUpdate(0), 300);
}
}, [forceUpdate]);
// useEffect(() => {
// if (forceUpdate !== 0) {
// setTimeout(() => setForceUpdate(0), 300);
// }
// }, [forceUpdate]);

return (
<div
className="modal fade"
id="staticBackdrop"
data-bs-backdrop="static"
data-bs-keyboard="false"
tabIndex={-1}
aria-labelledby="staticBackdropLabel"
aria-hidden="true"
role="dialog"
>
<div
className="modal-dialog .modal-lg modal-dialog-centered modal-dialog-scrollable"
role="document"
>
<div className="modal-content">
<div className="modal-header">
<h2 className="devtools-modal-title" id="staticBackdropLabel">
JSON Preview
</h2>
<span
className="json-copy"
onClick={(e) => copyObject(JSON.stringify(filteredJson))}
aria-hidden="true"
>
<Tooltip
content={forceUpdate === 0 ? 'Copy' : 'Copied'}
direction="top"
dynamic
delay={200}
status={forceUpdate}
>
<img src="/copy.svg" alt="copy icon" />
</Tooltip>
</span>
<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"
displayDataTypes={false}
enableClipboard={false}
style={{ color: '#C8501E' }}
/>
)}
</pre>
) : (
''
)}
</div>
<div className="modal-footer">
<button
type="button"
className="btn tertiary-btn modal-btn"
data-bs-dismiss="modal"
>
Close
</button>
</div>
</div>
</div>
</div>
);
};
export default DevTools;
// return (
// <div
// className="modal fade"
// id="staticBackdrop"
// data-bs-backdrop="static"
// data-bs-keyboard="false"
// tabIndex={-1}
// aria-labelledby="staticBackdropLabel"
// aria-hidden="true"
// role="dialog"
// >
// <div
// className="modal-dialog .modal-lg modal-dialog-centered modal-dialog-scrollable"
// role="document"
// >
// <div className="modal-content">
// <div className="modal-header">
// <h2 className="devtools-modal-title" id="staticBackdropLabel">
// JSON Preview
// </h2>
// <span
// className="json-copy"
// onClick={(e) => copyObject(JSON.stringify(filteredJson))}
// aria-hidden="true"
// >
// <Tooltip
// content={forceUpdate === 0 ? 'Copy' : 'Copied'}
// direction="top"
// dynamic
// delay={200}
// status={forceUpdate}
// >
// <img src="/copy.svg" alt="copy icon" />
// </Tooltip>
// </span>
// <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"
// displayDataTypes={false}
// enableClipboard={false}
// style={{ color: '#C8501E' }}
// />
// )}
// </pre>
// ) : (
// ''
// )}
// </div>
// <div className="modal-footer">
// <button
// type="button"
// className="btn tertiary-btn modal-btn"
// data-bs-dismiss="modal"
// >
// Close
// </button>
// </div>
// </div>
// </div>
// </div>
// );
// };
// export default DevTools;
Loading