lelouchB / final-space-api

Final Space API : RESTful API based on the show Final Space.
https://finalspaceapi.com
BSD 3-Clause "New" or "Revised" License
78 stars 47 forks source link

Add Docusarus Image Plugin and configure the images #33

Closed lelouchB closed 3 years ago

lelouchB commented 3 years ago

Docusarus provides ideal image plugin. This plugin will optimize images in the production build.

https://v2.docusaurus.io/docs/using-plugins#docusaurusplugin-ideal-image

Add this plugin and update the images in the frontend folder, specifically the images on the landing page

Here is the permalink for the code that needs to be updated

https://github.com/lelouchB/final-space-api/blob/9a4f0d6b36074ba1350b452b3b5eab5f5c0704ed/frontend/src/pages/Components/Body/_Card.js#L12

fluentinstroll commented 3 years ago

Hi! Can I handle this issue?

lelouchB commented 3 years ago

Hey @fluentinstroll I will assign this to you.

Let me know if you have any questions.

Looking forward to your contributions.

lelouchB commented 3 years ago

@fluentinstroll Any update on this ?

Just checking in. Thanks

fluentinstroll commented 3 years ago

Hey @lelouchB

I should have a pull request up today for this issue.

lelouchB commented 3 years ago

@fluentinstroll Awesome Looking forward to it.

fluentinstroll commented 3 years ago

@lelouchB

Hello! Just providing an update for you: I've been working on this for a few hours now and have hit a couple snags, I want to start by saying I'm fairly new to React and Docusaurus so I thought I'd document this in case you have any insight.

The first was when trying to use "useBaseUrl" like my below example, the tag was throwing errors.

<Image img={require(useBaseUrl(`img/${props.charName}.png`))}
                height="300px"
                alt={props.charName}
                />

Instead, I decided to go with a relative path that didn't make use of baseUrl.

<Image img={require(`../../../../static/img/${props.charName}.png`)}
                height="300px"
                alt={props.charName}
                /> 

After this, the files showed up in the build/ideal-img folder like they're supposed to: image

However, again I had a "TypeError: Cannot read property 'height' of undefined' when trying to compile. I'm presuming now that this is due to how Docusaurus's "Image" class interacts with React's "IdealImage" class but I'm not sure at this moment what the solution is.

Anyway, I'm going to pick this up again in a few hours but I thought I'd jot my thoughts down here.

Thanks!

harsh599 commented 3 years ago

Yes I have also been working on this issue parallely along with you I am also stuck at this point only having same "height of undefined"type error

harsh599 commented 3 years ago

Yes I have also been working on this issue parallely along with you I am also stuck at this point only having same "height of undefined"type error

image

lelouchB commented 3 years ago

@harsh599 and @fluentinstroll I understand your issue, I am exploring it. Will get back to you on this. Thanks

slorber commented 3 years ago

@harsh599 if you want me to help, please open a good bug report.

https://v2.docusaurus.io/docs/using-plugins/#docusaurusplugin-ideal-image

I don't think using dynamic require paths with template literal strings is a good idea. Try to use constant paths.

Also, I wonder if there's not a typo in our documentation. For require() calls, you should read the default export, so maybe try to add a .default at the end:


So instead of

<Image img={require(`./path/to/${dynamic}.png`)} />

try this:

<Image img={require('./path/to/staticImage.png').default} />
lelouchB commented 3 years ago

Closing this issue Two reasons

Thanks @fluentinstroll