-
Notifications
You must be signed in to change notification settings - Fork 3
Editor mode #56
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
Editor mode #56
Conversation
✅ Deploy Preview for alex-code-blog ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
helpers/markdownDocumentsReader.ts
Outdated
| const docs = slugs | ||
| .map((slug) => getPostDocumentBySlug(slug)) | ||
| .filter((post: PostDocument) => { | ||
| if (isPostADraft(post) || isPostInTheFuture(post)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We repeat those lines of code a lot
isPostADraft(post) || isPostInTheFuture(post)Create a combined helper isUpcomingPost
5e147db to
4649e63
Compare
components/Intro.tsx
Outdated
| const [isFirstRender, setIsFirstRender] = useState(true); | ||
|
|
||
| const handleClick = () => { | ||
| if (admin === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (admin === true) { | |
| if (admin) { |
It's a same thing
| imageWrapper?.setAttribute("admin", ""); | ||
| editIcon?.setAttribute("admin", ""); | ||
| setIsFirstRender(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a break line down below, for the consistency
components/Intro.tsx
Outdated
| editIcon?.setAttribute("admin", ""); | ||
| setIsFirstRender(false); | ||
| } | ||
| if (!admin && isFirstRender === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!admin && isFirstRender === false) { | |
| if (!admin && !isFirstRender) { |
Use the same syntax for both of them
components/Intro.tsx
Outdated
| }, [admin, isFirstRender]); | ||
|
|
||
| return ( | ||
| <section className="intro-section"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do MUI in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#82 - refactor of MUI component. I think it will be easier for you to check this refactor if it will be like another PR.
| ? "grayscale(50%)" | ||
| : "none", | ||
|
|
||
| filter: isUpcomingPost(post) ? "grayscale(50%)" : "none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this utility function
|
|
||
| export function getUpcomingPosts(): PostDocumentWithoutContent[] { | ||
| const slugs = fs.readdirSync(documentsDirectory); | ||
| const docs = slugs | ||
| .map((slug) => getPostDocumentBySlug(slug)) | ||
| .filter((post: PostDocument) => isUpcomingPost(post)) | ||
| .sort((post1, post2) => (post1.date > post2.date ? -1 : 1)) | ||
| .map((post) => { | ||
| const { content, ...postWithoutContent } = post; | ||
| return postWithoutContent; | ||
| }); | ||
|
|
||
| return JSONSerialize(docs); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tina CMS is fetching posts somewhat differently, so it might cause some merge conflicts
I might merge Tina first, and only then you're going to update this utility method
pages/_app.tsx
Outdated
| import AdminProvider from "@/components/AdminProvider"; | ||
| import ThemeProvider from "@/components/MUI/ThemeProvider"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import AdminProvider from "@/components/AdminProvider"; | |
| import ThemeProvider from "@/components/MUI/ThemeProvider"; | |
| import AdminProvider from "components/AdminProvider"; | |
| import ThemeProvider from "components/MUI/ThemeProvider"; |
It's a same thing, is there any reason we're using @ symbol?
pages/index.tsx
Outdated
| <section className="simple-section"> | ||
| <div className="container"> | ||
| {admin && <UpcomingPosts posts={upcomingPosts} />} | ||
| {/* TODO: Implement tags count for the admin user */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've done this TODO item
| const posts = getUpcomingPosts(); | ||
|
|
||
| res.status(200).json(posts); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tina GraphQL query might look a bit differently, so just heads up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, waiting for merge of Tina and after will be fixing that
styles/main.scss
Outdated
| } | ||
|
|
||
| .intro-avatar .image img { | ||
| .intro-avatar .image-avatar:after { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't need it with MUI, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea. I add the PR with refactor of Intro component to mui. I think it will be easier for you to check this refactor if it will be like another PR. #82
Refactor intro section component to mui
No description provided.