GithubHelp home page GithubHelp logo

Comments (4)

DmitryKorlas avatar DmitryKorlas commented on April 29, 2024 1

Regarding my specific case with GitLab artifacts deployment for merge requests, I couldn't find the ability to implement a redirect on the GitLab side. GitLab integration requires an index.html file for viewing artifacts of MR.

I added a workaround trick to replace the URL on the client side. It looks messy, and I don't like it, but it resolved the issue. Perhaps it can be helpful to someone else:

// docusaurus.config.ts
import type {Config, HtmlTagObject} from '@docusaurus/types';

// see https://github.com/facebook/docusaurus/issues/9916
const redirect = `
(function() {
  var pathname = window.location.pathname;
  if (pathname.endsWith('index.html')) {
    history.replaceState(
      null,
      pathname,
      pathname.replace('index.html', '')
    );
  }
})();
`.replace(/\n/g, '');

const config: Config = {
  // ...
  headTags: [
    {
      tagName: 'script',
      attributes: {
        src: 'data:text/javascript,' + redirect,
      },
    },
  ] satisfies HtmlTagObject[],
};

from docusaurus.

slorber avatar slorber commented on April 29, 2024 1

We'll try to fix this for V4 in #10059

from docusaurus.

slorber avatar slorber commented on April 29, 2024

This has already been discussed here:

See my suggestions here: #9871 (comment)

You should serve pages by their canonical URLs. By default, this means serving them without the .html extension.

If this is a problem, there's often a "pretty URL" option on CDNs and static hosts you can turn on, otherwise you can use reverse proxy settings.

from docusaurus.

DmitryKorlas avatar DmitryKorlas commented on April 29, 2024

Thanks for your response and valuable feedback! Maybe it would be helpful to mention about new behavior at the migration guides. I followed the instructions step by step, but this behavior was unexpected.

from docusaurus.

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.