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

Server render search results (search and channel pages) #1836

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

jonkafton
Copy link
Contributor

@jonkafton jonkafton commented Nov 20, 2024

What are the relevant tickets?

Closes:
Next.js: Search page: Prefetch API calls #6035
Next.js: Channel details page search: Prefetch API calls #6037

Description (What does it do?)

Prefetches search results for the search and channel details pages.

Dependency on #1846 to merge first - this is need to apply user list and learning path relationships to the learning resources (server rendered resources won't have them). Done.

This also needs mitodl/course-search-utils#159 to be published before merging. Done.

How can this be tested?

On the search page /search and channel pages e.g. /c/topic/architecture, /c/department/media-arts-and-sciences, /c/unit/mitx, make various changes to the following, refreshing after each and ensuring that the search results are prerendered on the server with no calls made to /api/v1/learning_resources_search/ on first render and no prefetch warnings in the dev tools console:

  • Search q text
  • Filter facet selections
  • Resource category tab selection
  • Page selection

The search results should render ok on first load with JavaScript disabled in the dev tools debugger settings.

Additional Context

Includes some refactoring to pull out getSearchParams() for reuse and provide a requestSearchParams() to convert Next.js parsed querystrings to our params for learningResources.search() API calls.

@jonkafton jonkafton marked this pull request as ready for review November 22, 2024 15:41
@jonkafton jonkafton added the Needs Review An open Pull Request that is ready for review label Nov 22, 2024
@abeglova abeglova self-assigned this Nov 25, 2024
@abeglova
Copy link
Contributor

The search results don't seem to be pre-rendered but I'm guessing it's something wrong with my development environment. Will message you about it first thing tomorrow morning since you're probably done for the day

@jonkafton
Copy link
Contributor Author

The search results don't seem to be pre-rendered but I'm guessing it's something wrong with my development environment. Will message you about it first thing tomorrow morning since you're probably done for the day

I've removed a cache invalidation just now in 8d52ff1, which we no longer need and which would cause the search API to be called again on page load. This wouldn't have been preventing server rendering but could that have been the reason it didn't appear to be server rendering?

Copy link
Contributor

@abeglova abeglova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review An open Pull Request that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants