Skip to content

Commit

Permalink
chore: added 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
RamK777-stack committed May 19, 2024
1 parent eac80ef commit 092d055
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Binary file added public/svg/404.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion src/app/[_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { OutputData } from '@editorjs/editorjs';
import dynamic from 'next/dynamic';
import Image from 'next/image';
import { useEffect, useState } from 'react';
import '@/lib/env';

Expand Down Expand Up @@ -37,7 +38,19 @@ export default function HomePage({ params }: { params: { _id: string } }) {

return (
<section className='bg-white'>
<Editor content={content} onlyReadable={true} />
{!content ? (
<div className='flex justify-center mt-10 text-xl'>
<Image
src='/svg/404.gif'
className='h-48 rounded'
height={20}
width={200}
alt='404 not found'
/>
</div>
) : (
<Editor content={content} onlyReadable={true} />
)}
</section>
);
}
16 changes: 2 additions & 14 deletions src/app/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ import Underline from '@editorjs/underline';
import Warning from '@editorjs/warning';
import { useEffect, useRef, useState } from 'react';

const DEFAULT_INITIAL_DATA = {
time: new Date().getTime(),
blocks: [
{
type: 'header',
data: {
text: 'Type something...',
level: 2,
},
},
],
};

interface PropTypes {
content?: OutputData | null;
onlyReadable?: boolean;
Expand All @@ -90,13 +77,14 @@ export default function Editor({ saveData, content, onlyReadable }: PropTypes) {

const initEditor = () => {
const editor = new EditorJS({
placeholder: 'Let`s write an awesome story!',
holder: 'editorjs',
onReady: () => {
ejInstance.current = editor;
},
autofocus: true,
readOnly: onlyReadable || false,
data: content || DEFAULT_INITIAL_DATA,
data: content || undefined,
onChange: async () => {
if (!onlyReadable) {
const contentData = await editor.saver.save();
Expand Down
1 change: 1 addition & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '@/styles/globals.css';
// !STARTERCONF This is for demo purposes, remove @/styles/colors.css import immediately
import '@/styles/colors.css';

// import '@/styles/custom.css'
import Footer from '@/app/components/Footer';
import Header from '@/app/components/Header';
import { Toaster } from '@/app/components/ui/sonner';
Expand Down
3 changes: 3 additions & 0 deletions src/styles/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ce-paragraph.cdx-block:empty {
display: none;
}

0 comments on commit 092d055

Please sign in to comment.