From f8314237d4cca71aa3ec38346ceec74fdac2b69a Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 23 Jul 2026 21:59:39 +0800 Subject: [PATCH 1/3] feat: remove disqus identifier for comment migration [build] --- website/src/views/components/disqus/CommentCount.tsx | 8 ++------ website/src/views/components/disqus/DisqusComments.tsx | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/website/src/views/components/disqus/CommentCount.tsx b/website/src/views/components/disqus/CommentCount.tsx index 480354052d..ad3001b297 100644 --- a/website/src/views/components/disqus/CommentCount.tsx +++ b/website/src/views/components/disqus/CommentCount.tsx @@ -33,7 +33,7 @@ function loadInstance() { } } -export const CommentCountComponent: React.FC = ({ identifier, url, loadDisqusManually }) => { +export const CommentCountComponent: React.FC = ({ url, loadDisqusManually }) => { useEffect(() => { if (!loadDisqusManually) { loadInstance(); @@ -47,11 +47,7 @@ export const CommentCountComponent: React.FC = ({ identifier, url, loadDi - + ); }; diff --git a/website/src/views/components/disqus/DisqusComments.tsx b/website/src/views/components/disqus/DisqusComments.tsx index d7bb9c0219..1c5e7f4607 100644 --- a/website/src/views/components/disqus/DisqusComments.tsx +++ b/website/src/views/components/disqus/DisqusComments.tsx @@ -72,12 +72,11 @@ class DisqusComments extends PureComponent { // Disqus is configured using a function that modifies 'this', so we cannot use // arrow functions here, which also means we need to rebind values from the outer // this if we need to use them inside the function - const { identifier, url, title } = this.props; + const { url, title } = this.props; // Can't be arsed to type this bullshit // eslint-disable-next-line @typescript-eslint/no-explicit-any return function configDisqus(this: any) { - this.page.identifier = identifier; this.page.url = url; this.page.title = title; }; From 494e8e734db29f1da78e06f3dfdc4f8954db7337 Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 23 Jul 2026 22:08:09 +0800 Subject: [PATCH 2/3] cleanup: remove identifier field [build] --- website/src/types/views.ts | 1 - website/src/views/components/disqus/CommentCount.test.tsx | 1 - website/src/views/modules/ModulePageContent.tsx | 1 - 3 files changed, 3 deletions(-) diff --git a/website/src/types/views.ts b/website/src/types/views.ts index 2b022a422e..84ea88016f 100644 --- a/website/src/types/views.ts +++ b/website/src/types/views.ts @@ -32,7 +32,6 @@ export type RefinementItem = { key: string; doc_count?: number; missing?: boolea export type RefinementDisplayItem = RefinementItem & { selected: boolean }; export type DisqusConfig = { - readonly identifier: string; readonly url: string; readonly title: string; }; diff --git a/website/src/views/components/disqus/CommentCount.test.tsx b/website/src/views/components/disqus/CommentCount.test.tsx index 6221495df8..b36944db37 100644 --- a/website/src/views/components/disqus/CommentCount.test.tsx +++ b/website/src/views/components/disqus/CommentCount.test.tsx @@ -10,7 +10,6 @@ vi.mock('utils/insertScript', () => ({ default: vi.fn() })); const disqusConfig = { url: 'https://nusmods.com/courses/CS1010/reviews', - identifier: 'CS1010', title: 'CS1010 Programming Methodology', }; diff --git a/website/src/views/modules/ModulePageContent.tsx b/website/src/views/modules/ModulePageContent.tsx index 9e5964ceff..ef89c86376 100644 --- a/website/src/views/modules/ModulePageContent.tsx +++ b/website/src/views/modules/ModulePageContent.tsx @@ -60,7 +60,6 @@ const ModulePageContent: React.FC = ({ module, archiveYear }) => { const disqusConfig = { url: `https://nusmods.com/courses/${moduleCode}/reviews`, - identifier: moduleCode, title: pageTitle, }; From a2e86cd1364552c126e99eb296b2541e9a1a182a Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 23 Jul 2026 22:20:38 +0800 Subject: [PATCH 3/3] fix: add stable identifier [build] --- website/src/types/views.ts | 1 + website/src/views/components/disqus/CommentCount.test.tsx | 1 + website/src/views/components/disqus/CommentCount.tsx | 8 ++++++-- website/src/views/components/disqus/DisqusComments.tsx | 3 ++- website/src/views/modules/ModulePageContent.tsx | 4 ++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/website/src/types/views.ts b/website/src/types/views.ts index 84ea88016f..2b022a422e 100644 --- a/website/src/types/views.ts +++ b/website/src/types/views.ts @@ -32,6 +32,7 @@ export type RefinementItem = { key: string; doc_count?: number; missing?: boolea export type RefinementDisplayItem = RefinementItem & { selected: boolean }; export type DisqusConfig = { + readonly identifier: string; readonly url: string; readonly title: string; }; diff --git a/website/src/views/components/disqus/CommentCount.test.tsx b/website/src/views/components/disqus/CommentCount.test.tsx index b36944db37..801bbb45ca 100644 --- a/website/src/views/components/disqus/CommentCount.test.tsx +++ b/website/src/views/components/disqus/CommentCount.test.tsx @@ -9,6 +9,7 @@ vi.mock('utils/insertScript', () => ({ default: vi.fn() })); (insertScript as MockedFunction).mockResolvedValue(new Event('mock event')); const disqusConfig = { + identifier: 'CS1010', url: 'https://nusmods.com/courses/CS1010/reviews', title: 'CS1010 Programming Methodology', }; diff --git a/website/src/views/components/disqus/CommentCount.tsx b/website/src/views/components/disqus/CommentCount.tsx index ad3001b297..480354052d 100644 --- a/website/src/views/components/disqus/CommentCount.tsx +++ b/website/src/views/components/disqus/CommentCount.tsx @@ -33,7 +33,7 @@ function loadInstance() { } } -export const CommentCountComponent: React.FC = ({ url, loadDisqusManually }) => { +export const CommentCountComponent: React.FC = ({ identifier, url, loadDisqusManually }) => { useEffect(() => { if (!loadDisqusManually) { loadInstance(); @@ -47,7 +47,11 @@ export const CommentCountComponent: React.FC = ({ url, loadDisqusManually - + ); }; diff --git a/website/src/views/components/disqus/DisqusComments.tsx b/website/src/views/components/disqus/DisqusComments.tsx index 1c5e7f4607..d7bb9c0219 100644 --- a/website/src/views/components/disqus/DisqusComments.tsx +++ b/website/src/views/components/disqus/DisqusComments.tsx @@ -72,11 +72,12 @@ class DisqusComments extends PureComponent { // Disqus is configured using a function that modifies 'this', so we cannot use // arrow functions here, which also means we need to rebind values from the outer // this if we need to use them inside the function - const { url, title } = this.props; + const { identifier, url, title } = this.props; // Can't be arsed to type this bullshit // eslint-disable-next-line @typescript-eslint/no-explicit-any return function configDisqus(this: any) { + this.page.identifier = identifier; this.page.url = url; this.page.title = title; }; diff --git a/website/src/views/modules/ModulePageContent.tsx b/website/src/views/modules/ModulePageContent.tsx index ef89c86376..c07c3804b8 100644 --- a/website/src/views/modules/ModulePageContent.tsx +++ b/website/src/views/modules/ModulePageContent.tsx @@ -57,8 +57,12 @@ const ModulePageContent: React.FC = ({ module, archiveYear }) => { const semesters = getSemestersOffered(module); const isArchive = !!archiveYear; const offered = isOffered(module); + const disqusIdentifier = Array.from(new Set([moduleCode, ...(module.aliases ?? [])])) + .sort() + .join('/'); const disqusConfig = { + identifier: disqusIdentifier, url: `https://nusmods.com/courses/${moduleCode}/reviews`, title: pageTitle, };