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

Documentation change title based on current uri hash? #218

Open
SimonLSchlee opened this issue Sep 18, 2022 · 1 comment
Open

Documentation change title based on current uri hash? #218

SimonLSchlee opened this issue Sep 18, 2022 · 1 comment

Comments

@SimonLSchlee
Copy link

The documentation always uses Documentation - The Zig Programming Language as the title.

Personally I found that unfortunate, because I regularly have a lot of open tabs and all of them having the same name doesn't help me in finding the right one to switch to.

Looking at the source code of the documentation it seems to avoid any usage of javascript.
Is that a deliberate choice, or are quality of life enhancements via javascript wanted?

Currently I am using a simple userscript (via tampermonkey extension) that rewrites the title:

// ==UserScript==
// @name         zig distinct documentation titles
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  rewrite documentation title
// @author       You
// @match        https://ziglang.org/documentation/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ziglang.org
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let update_title = function() {
        let h = window.location.hash.slice(1);
        if(h !== "") {
            let new_title = h.replaceAll("-", " ").replace("toc ", "");
            document.title = new_title + " - Zig";
        }
    };

    update_title();
    addEventListener('hashchange', update_title);
})();

This issue is mostly a suggestion to add something similar to the generated html file.
If something like this is not wanted I will continue to use the userscript.

I just thought I should mention it, in case others would prefer a changing title too.

@kristoff-it
Copy link
Member

Is that a deliberate choice, or are quality of life enhancements via javascript wanted?

It definitely used to be the case, that said, I don't see anything wrong with something that gracefully degrades. I'll keep this in mind as we plan changes to the language reference.

Also keeping this issue open as a reminder.
Thanks for your comment.

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

No branches or pull requests

2 participants