Skip to content

Commit

Permalink
Add post widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corofides committed Nov 1, 2023
1 parent 096732a commit 48cba56
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/pages/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"location": "/posts/:id",
"title": "Post",
"widgets": [
{"name": "Header", "children": ["Blog Post"], "colSpan": 3, "_id": ""}
{"name": "Post", "children": [], "colSpan": 3, "_id": ""}
]
}]
22 changes: 22 additions & 0 deletions src/Widgets/Post/Post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, {useEffect, useState} from 'react';
import usePosts from '../../Hooks/usePosts';
import Readme from "../Readme/Readme";

const Post = ({id, ...props}) => {

const {loading, getPost} = usePosts();

if (loading) {
return null;
}

const post = getPost(Number(id));


return (
<Readme readmeUrl={"/Shimmer/posts/" + post.file} {...props} />
)

};

export default Post;
1 change: 1 addition & 0 deletions src/Widgets/Post/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default} from './Post';
2 changes: 2 additions & 0 deletions src/Widgets/Widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Text from './Text';
import PostPreview from './PostPreview';
import Readme from './Readme';
import Accordion from './Accordion';
import Post from './Post';
import { css } from 'glamor';

const Widgets = ({Cmp, children = null, colPos = 1, colSpan = 1, ...other}) => {
Expand All @@ -20,6 +21,7 @@ const Widgets = ({Cmp, children = null, colPos = 1, colSpan = 1, ...other}) => {
"PostPreview": PostPreview,
"Readme": Readme,
"Accordion": Accordion,
"Post": Post,
};

if (!widgetComponents[Cmp]) {
Expand Down

0 comments on commit 48cba56

Please sign in to comment.