tripos-education / maths-tripos-questions

Archive of questions from the Cambridge Mathematics Tripos
MIT License
9 stars 7 forks source link

[enhancement to deal with silly edge cases] Change giscus discussion linking to be based off question data rather than url #243

Open thenewtonium opened 2 years ago

thenewtonium commented 2 years ago

Basically at the moment silly things can happen like if you go to part-ii/20XX-XX/index.html it loads a different discussion to part-ii/20XX-XX/ because it's basing the discussion to load off the URL. This is obviously an unrealistic edge case, but changing how the giscus widget is generated on each page would be useful e.g. if we wanted to change the URL structure of the site without wiping the comments off each question. Also for resolving #228 I guess.

AustenLamacraft commented 2 years ago

Oh, this is nasty, but it sounds like a Giscus level bug. Do you want to raise it there?

By the way, I tried this and got no discussion for /index.html. Do you really sometimes get a different discussion?

thenewtonium commented 2 years ago

Well by a different discussion I meant one without the comments from the page without index.html. Btw, I just tested on #245 and it did create a different discussion, which is now loaded on part-ii/2018-112/ as well presumably for the same reason as #228 ... (P.S. you should probably delete #245 so that @silkca 's comment is visible again... sorry)

thenewtonium commented 2 years ago

Anyway I wouldn't say this is necessarily a giscus bug (rather than intended behaviour) - giscus does allow different ways to link pages and discussions; my suggestion was to use question data to generate the correct discussion title then pass this into the giscus widget loader script include.

AustenLamacraft commented 2 years ago

The options are pathname (currently using), url, <title> or <og:title>. I'm actually using <title> for the text in the discussion body (and link on the frontpage) e.g. "Part II 2018 Principles of Quantum Mechanics: Paper 4, Section II, D". That's good for humans to read but still isn't unique.

This is probably all a weakness of the whole approach. Wouldn't it be better to associate a unique ID with each page, and pass that into Giscus?

Still, Giscus shouldn't be creating separate comments for pathname/ and pathname/index.html, should it?