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

Fixes runtime rendering of mdx in cms preview #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "find . -name \"node_modules\" -type d -prune -exec rm -rf '{}' + && yarn && yarn gatsby-clean"
},
"dependencies": {
"@openeventkit/event-site": "2.0.108-beta.9",
"@openeventkit/event-site": "2.0.108-beta.11",
"gatsby": "5.9.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Grid from "../../../../components/Grid";
import SpeakerCard from "../../../../components/SpeakerCard";
import ResponsiveImage from "../../../../components/ResponsiveImage";

const shortcodes = {
Grid,
SpeakerCard
SpeakerCard,
"img": ResponsiveImage,
};

export default shortcodes;
30 changes: 30 additions & 0 deletions src/components/ResponsiveImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import PropTypes from "prop-types";

const imageStyles = {
maxWidth: "100%",
height: "auto"
};

const ResponsiveImage = ({ src, alt, maxWidth = "100%", padding = "0" }) => {
const containerStyles = {
maxWidth: maxWidth,
padding: padding,
display: "flex",
justifyContent: "center"
};
return (
<div style={containerStyles}>
<img src={src} alt={alt} style={imageStyles} />
</div>
);
};

ResponsiveImage.propTypes = {
src: PropTypes.string.isRequired,
alt: PropTypes.string.isRequired,
maxWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
};

export default ResponsiveImage;
9 changes: 6 additions & 3 deletions src/components/SpeakerCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { cloneElement } from "react";
import PropTypes from "prop-types";

const cardStyle = {
Expand Down Expand Up @@ -27,11 +27,14 @@ const pStyle = {
marginBottom: 0
};

const SpeakerCard = ({ name, role, children }) => {
const SpeakerCard = ({ name, role, children, ...props }) => {
const childrenWithProps = React.Children.map(children, child =>
cloneElement(child, { ...props })
);
return (
<div style={cardStyle}>
<div style={innerContainerStyle}>
<div style={contentStyle}>{children}</div>
<div style={contentStyle}>{childrenWithProps}</div>
<div style={textStyle}>
<p style={pStyle}>
<b>{name}</b><br/>
Expand Down
Loading