jakartaee / jakarta.ee

Jakarta EE is the future of cloud native Java. Jakarta EE open source software drives cloud native innovation, modernizes enterprise applications and protects investments in Java EE.
https://jakarta.ee
Eclipse Public License 2.0
160 stars 94 forks source link

ZH Site - Broken Links in persistence 3.2 #1970

Closed lukasj closed 2 weeks ago

lukasj commented 1 month ago

https://jakarta.ee/zh/specifications/persistence/3.2/ page points to non-existing pages:

Response 404: https://jakarta.ee/zh/projects/
Response 404: https://jakarta.ee/zh/specifications/persistence/3.2/apidocs
Response 404: https://jakarta.ee/zh/specifications/persistence/3.2/jakarta-persistence-spec-3.2.html
oliviergoulet5 commented 4 weeks ago

Hi @lukasj, thanks for opening the issue!

The projects page is now fixed: https://jakarta.ee/zh/projects/

As for the specification pages, I will need to look deeper into why these pages aren't available.

ZacharySabourin commented 3 weeks ago

After a bit of investigation, it appears that only .md extension files are being imported by the specifications build script: https://github.com/jakartaee/jakarta.ee/blob/03d58ef6288a168b40b526ab5f206063e0b4a190/build.sh#L54

This is why pages like this work: https://jakarta.ee/zh/specifications/persistence/3.2/

But a page like this does not: https://jakarta.ee/zh/specifications/persistence/3.2/apidocs

In this case, the apidocs folder does not contain any markdown pages and therefore all contained files are ignored by the script.

We are currently translating each file individually. We could try translation by content directory, but I'm not convinced this would solve our problem. It would also create a ton of duplication in the repo.

We could also try modifying the script to forcefully import all "non-markdown" content without adding the language extension.

@chrisguindon Thoughts?

chrisguindon commented 3 weeks ago

@ZacharySabourin I have an idea, let me test it out first.. I am hoping we can fix this without modifying this script and having to duplicate all the assets for all the languages..

chrisguindon commented 3 weeks ago

@ZacharySabourin After taking a closer look I was able to see that the root of the issue lies with relative links: https://raw.githubusercontent.com/jakartaee/specifications/master/persistence/3.2/_index.md

* [Jakarta Persistence 3.2 Specification Document](./jakarta-persistence-spec-3.2.pdf) (PDF)
* [Jakarta Persistence 3.2 Specification Document](./jakarta-persistence-spec-3.2.html) (HTML)
* [Jakarta Persistence 3.2 Javadoc](./apidocs)

I did a quick test and I was able to make the link works by setting a <base> tag: https://www.w3schools.com/tags/tag_base.asp#:~:text=Definition%20and%20Usage,inside%20the%20element.

I added the following to layouts/partials/head_custom.html:

{{ if or (eq .Section "specifications") (strings.HasPrefix .Section "specifications/") }}
<base href="/specifications/persistence/3.2/" />
{{ end }}

However, we can't hardcode the base as I did in my test. To consider this a possible solution, we would need to find a way set the base to the default English URL programmatically. I am thinking this would be a better solution if we can make this work as it would not require us to duplicate a bunch of content.

ZacharySabourin commented 3 weeks ago

@chrisguindon Interesting solution. I will poke at this tomorrow and see what I can come up with.