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

fix: fix docs og gen failing for versioned and localized docs #193

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Kas-tle
Copy link

@Kas-tle Kas-tle commented Mar 23, 2024

Signed-off-by: Joshua Castle [email protected]

Description:

This PR modifies docusaurus-og's getHtmlPath function to use doc.metadata.slug instead of doc.metadata.permalink

Related Issue(s):

N/A

Changes Included:

  • Bugfix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Refactoring (a change that improves code quality and/or architecture)
  • Other (explain below)

Implementation Details:

Currently, getHtmlPath of docs.plugin.ts for docusaurus-og uses doc.metadata.permalink, but this causes undesired behavior when localized or versioned docs are used. This is because this.context.outDir already contains the locale and version in the path, which is again passed by doc.metadata.permalink. This leads to double versions and/or locales in the path passed to Docusaurus, which causes this error:

Error: Unable to build website for locale de.
    at tryToBuildLocale (/home/jdcastle/repos/GeyserMC/GeyserWebsite/node_modules/@docusaurus/core/lib/commands/build.js:55:19)
    at async mapAsyncSequential (/home/jdcastle/repos/GeyserMC/GeyserWebsite/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
    at async Command.build (/home/jdcastle/repos/GeyserMC/GeyserWebsite/node_modules/@docusaurus/core/lib/commands/build.js:82:21) {
  [cause]: [Error: ENOENT: no such file or directory, open '/home/jdcastle/repos/GeyserMC/GeyserWebsite/build/de/de/api/api.geysermc.org/global-api/index.html'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/home/jdcastle/repos/GeyserMC/GeyserWebsite/build/de/de/api/api.geysermc.org/global-api/index.html'
  }
}

Testing:

Testing was done by using the docusaurus-og on a site with locales other than the default locale. The change allowed preview images to generate and a successful build for both the default locale and the additional locale.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant