Coder Social home page Coder Social logo

Comments (7)

minimalsm avatar minimalsm commented on May 29, 2024 1

@kamuik16 I think you're right.

The bug looks like it was introduced in this commit during the migration from Gatsby to NextJS.

For context, our English links before the migration had the en prefix (e.g., https://ethereum.org/en/), but during the migration, we removed them for English but kept them in all other languages (e.g., https://ethereum.org for English, https://ethereum.org/fr/ for French).

In this PR (which was merged yesterday, and will go live soon), we re-added the en prefix for English, so this bug is now also present in English (see deploy preview from that PR: https://deploy-preview-12134--ethereumorg.netlify.app/en/assets/).

To solve this, I think we need to add the lang prefix to the src in the AssetDownloadImage component.

cc: @pettinarip @wackerow

from ethereum-org-website.

kamuik16 avatar kamuik16 commented on May 29, 2024

I think the problem here is the path definition.
When English is selected as a language the path to any svg i.e. is https://ethereum.org/assets/svgs/eth-diamond-glyph.svg while if any other language is selected the svg's path link adds the language abbreviation in it.
For e.g. for French it becomes https://ethereum.org/fr/assets/svgs/eth-diamond-glyph.svg and for Italian it becomes https://ethereum.org/it/assets/svgs/eth-diamond-glyph.svg. Notice fr and it gets added in the link. This problem is with all the svg links on the page.

I looked around but couldn't figure it out how to solve this.

from ethereum-org-website.

FaybianB avatar FaybianB commented on May 29, 2024

@minimalsm May I be assigned this issue?

from ethereum-org-website.

minimalsm avatar minimalsm commented on May 29, 2024

Hey @FaybianB thanks for offering to help!

Sure, all yours :)!

from ethereum-org-website.

FaybianB avatar FaybianB commented on May 29, 2024

The scope of this seems to include all image files, not just SVGs.

This setting seems to be the root cause of the issue because it adds the language prefix to the src urls for the images as well:

https://github.com/ethereum/ethereum-org-website/blob/dev/next-i18next.config.js#L14

I haven't found the exact location that's prepending the language to the image's href but that's what's happening.

We need to remove this language prefix from the href. I think this is happening within the next-i18next framework.

My approach right now is going to be to hack this middleware.ts function to include a fix to the href:

https://github.com/ethereum/ethereum-org-website/blob/dev/src/middleware.ts#L28

from ethereum-org-website.

wackerow avatar wackerow commented on May 29, 2024

@kamuik16 I think you're right.

The bug looks like it was introduced in this commit during the migration from Gatsby to NextJS.

The thing I see changed here is we're using a StaticImageData for our image... this is when we import an image as a component (ie. import SomeImage from "./some/path")... we then use const imgSrc = (image as StaticImageData).src inside AssetDownload to get the "source path"... but this is not an accessible path for downloading the image (both png's or svg's).

To get a "source path" that links to a downloadable image we may need to manually add this as a string prop for AssetDownload... ie:

import learnHero from "@/public/heroes/learn-hub-hero.png"

// ...

          <AssetDownload
            title={t("page-assets-learn-hero-name")}
            alt={t("page-assets-learn-hero-name")}
            image={learnHero}
            imgSrc="./heroes/learn-hub-hero.png"
            artistName="Liam Cobb"
            artistUrl="https://liamcobb.com/"
          />

...and then update AssetDownload to accept this prop and use it for the link href

@FaybianB Does that make sense? Using the .src property of a statically imported an image will break inside an href, but a string relative to the public directory should be available at https://ethereum.org/path/file.ext (for example, http://ethereum.org/heroes/learn-hub-hero.png)

from ethereum-org-website.

wackerow avatar wackerow commented on May 29, 2024

@pettinarip Not sure if you have a better suggestion here aside from just manually adding the src path string (relative to public) as a prop for AssetDownload

from ethereum-org-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.