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

feat: Basic content prefetch #1186

Merged
merged 7 commits into from
Nov 5, 2024
Merged

feat: Basic content prefetch #1186

merged 7 commits into from
Nov 5, 2024

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Oct 29, 2024

Simple prefetching for content in a few cases:

  • header links
  • sidebar links
  • links within markdown content
  • blog overview links

Makes for a bit snappier nav on desktop.

@rschristian rschristian force-pushed the feat/basic-prefetching branch from e6d29b9 to d0083ce Compare October 30, 2024 01:23
@rschristian rschristian changed the title feat: Basic content prefetch for links in header & sidebar feat: Basic content prefetch Oct 30, 2024
@rschristian rschristian force-pushed the feat/basic-prefetching branch from f031881 to 6a717dc Compare October 30, 2024 02:03
* @param {string} path
*/
export function prefetchContent(path) {
const lang = document.documentElement.lang;
Copy link
Member Author

Choose a reason for hiding this comment

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

This shouldn't be problematic, it's kept sync'd to the context value normally:

const setAndUpdateHtmlAttr = (lang) => {
setLang(lang);
document.documentElement.lang = lang;
};

While components could just pass it in & we can use the context normally, it's a bit more verbose and there's no reason to prefetch anything other than the currently set language, so abstracting it away is nicer.

@rschristian rschristian marked this pull request as ready for review October 30, 2024 02:56
@rschristian rschristian merged commit f227977 into master Nov 5, 2024
5 checks passed
@rschristian rschristian deleted the feat/basic-prefetching branch November 5, 2024 14:00
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

Successfully merging this pull request may close these issues.

2 participants