Skip to content

Sidebar active highlighting fails without .html URLs #2992

@qaqland

Description

@qaqland

Hi, I am using Cloudflare Pages to automatically build and host mdBook.
However, the class="active" in the sidebar was lost.

This may be related to how the website server handles URLs.
On my website 1, URLs ending with .html are by default redirected with 307/3082.

Not sure how to handle this properly here.

Related code:

// crates/mdbook-html/front-end/templates/toc.js.hbs

    connectedCallback() {
        this.innerHTML = '{{#toc}}{{/toc}}';
        // Set the current, active page, and reveal it if it's hidden
        let current_page = document.location.href.toString().split('#')[0].split('?')[0];
        if (current_page.endsWith('/')) {
            current_page += 'index.html';
        }

Footnotes

  1. https://hash.qaq.land

  2. https://developers.cloudflare.com/workers/static-assets/routing/advanced/html-handling/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions