mkdocs icon indicating copy to clipboard operation
mkdocs copied to clipboard

NoScript support

Open vanrein opened this issue 5 years ago • 9 comments

I love working with MkDocs, but the pages seem to be unusable for people without JavaScript. There are a few problems that should be relatively easy to resolve in <noscript/> sections:

Search cannot work without JavaScript. Removing the button would be kind, or perhaps linking to a search engine like DuckDuckGo with a site:xxx prefix could be a good alternative.

Menus conceal pages and make them unavailable to visitors without JavaScript. There are a few possible alternatives:

  1. Click on the menu for a separate page, which would need to be generated.
  2. More content in the left-hand menu; it might contain the page listing for those without JavaScript, and sort the current page entries under the listing.
  3. As a simplest alternative, the menu buttons could enter the first entry and allow continued clicking via Next. This does not work now.

(I had actually expected (and hoped) that 2. was the standard behaviour; I would have enabled it for all users, with or without JavaScript.)

MkDocs is lovely -- but I hope this is worth considering, because it seems to match with the purpose of simplicity and elegance behind MkDocs.

vanrein avatar Sep 28 '21 18:09 vanrein

Have you tried mkdocs-material theme? It fares much better in that regard.

In any case, all these issues you're mentioning would be theme-specific, so, which theme are you referring to?

oprypin avatar Sep 28 '21 20:09 oprypin

I am using the basic theme that came with the package. I will try the one you suggest and let you know.

I was indeed wondering how the split between theme and core would be; at least the idea of giving more context in the left-hand menu sounds like it would need core support and the same probably applies to separate pages with menu content?

vanrein avatar Sep 28 '21 21:09 vanrein

Themes cover both the pure frontend and also the generation of HTML. So actually, as I was saying, it's 100% (or, let's say 99%) up to each theme.

The "mkdocs" theme is indeed very outdated by now and I wouldn't recommend it as the first choice.

oprypin avatar Sep 28 '21 22:09 oprypin

Indeed. I had assumed the default would be omnipresent, but you seem to be saying that it's merely to start. I switched to readthedocs and now the experience is good. Thanks for explaining!

vanrein avatar Sep 29 '21 06:09 vanrein

Well, the report is still true though

oprypin avatar Sep 29 '21 06:09 oprypin

As you wish.

I played a little with the search box in readthedocs in 1.0.4, but was not happy with the result of this patch,

2c2
<   <form id ="rtd-search-form" class="wy-form" action="{{ base_url }}/search.html" method="get">
---
>   <form id ="rtd-search-form" class="wy-form" action="{{ base_url }}/search.html" method="get" hidden="true" >
4a5,13
>   <script>
>     document.getElementById ("rtd-search-form").hidden = false;
>   </script>
>   <noscript>
>     <em><small>(site works without scripts)</small></em>
>     <!-- wontwork:
>     <iframe src="https://duckduckgo.com/search.html?site=site.example.com&prefill=Search privately with DuckDuckGo" style="overflow:hidden;margin:0;padding:0;width:100%;height:30px;" frameborder="0" class="wy-form"></iframe>
>     -->
>   </noscript>

This removes the search box under NoScript, but the alternative search does not work (under NoScript, unless DuckDuckGo is exempted, I suppose).

Had it been more than half a success then I would have offered it as a patch, but this is at best a technical fragment -- setting a script-requiring chunk bit as hidden="true" and then looking it up with a script to set the flag to false. Trivial, I know.

vanrein avatar Oct 02 '21 12:10 vanrein

I think we can close this.

The built-in themes could do a better job of this in places, but there are alternatives available.

lovelydinosaur avatar Apr 10 '24 19:04 lovelydinosaur

What are the alternatives?

buhtz avatar May 29 '24 14:05 buhtz

As previously mentioned, Material for MkDocs works great without JavaScript! Disclaimer: I'm the author.

squidfunk avatar May 29 '24 15:05 squidfunk