add block sharing

This commit is contained in:
Mario
2020-10-16 22:33:02 +02:00
parent 0cb7bba521
commit e647d6e58e
7 changed files with 194 additions and 54 deletions
+18 -2
View File
@@ -6,7 +6,7 @@ import clsx from 'clsx';
import Breadcrumbs from '../Breadcrumbs';
import gallery from './gallery.json';
// import gallery from './gallery.json';
// import tutorials from '../../data/tutorials.json';
import { Link } from 'react-router-dom';
@@ -49,8 +49,24 @@ const styles = (theme) => ({
});
class GalleryHome extends Component {
state = {
gallery: []
}
componentDidMount() {
console.log(process.env.REACT_APP_BLOCKLY_API)
fetch(process.env.REACT_APP_BLOCKLY_API + this.props.location.pathname)
.then(res => res.json())
.then((data) => {
this.setState({ gallery: data })
})
}
render() {
return (
<div>
@@ -58,7 +74,7 @@ class GalleryHome extends Component {
<h1>Gallery</h1>
<Grid container spacing={2}>
{gallery.map((gallery, i) => {
{this.state.gallery.map((gallery, i) => {
return (
<Grid item xs={12} sm={6} md={4} xl={3} key={i} style={{}}>
<Link to={`/gallery/${gallery.id}`} style={{ textDecoration: 'none', color: 'inherit' }}>