-
Notifications
You must be signed in to change notification settings - Fork 536
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
image source issue #24
Comments
Fixed this in slug.tsx with: case "image":
const { format = {} } = value;
const {
block_width,
block_height,
display_source,
properties: image_properties,
block_aspect_ratio
} = format;
const baseBlockWidth = 768;
const roundFactor = Math.pow(10, 2);
// calculate percentages
const width = block_width
? `${Math.round(
(block_width / baseBlockWidth) * 100 * roundFactor
) / roundFactor}%`
: block_height || "100%";
const useWrapper = block_aspect_ratio && !block_height;
const childStyle: CSSProperties = useWrapper
? {
width: "100%",
height: "100%",
border: "none",
position: "absolute",
top: 0
}
: {
width,
border: "none",
height: block_height,
display: "block",
maxWidth: "100%"
};
return (
<img
key={!useWrapper ? id : undefined}
src={`/api/asset?assetUrl=${encodeURIComponent(
value.properties.source[0][0] as string
)}&blockId=${id}`}
style={childStyle}
/>
); |
Hi, how do we implement this in ReactJS? (not Typescript) |
otoyo
added a commit
to otoyo/notion-blog
that referenced
this issue
Dec 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found when I upload an image via notion , it can be rendered correctly , but I insert an image link which the image is outside notion. it can not be rendered correctly, its url is end with undefined.
The text was updated successfully, but these errors were encountered: