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

[DocSearch] Treat latest version as current version #418

Merged
merged 1 commit into from
Jan 26, 2018

Conversation

hramos
Copy link
Contributor

@hramos hramos commented Jan 25, 2018

If the site is versioned, and the latest version is displayed, the URL will not change. We need to let Algolia know this is the case.

This change assumes that sites have configured DocSearch to consider the 'current' tag as one matching the latest version of the site. You can see this is the case with React Native's own config.

The logic goes:

If a version is specified via props and it does not match the latest version, we'll use that version with DocSearch.

If a version is specified via props and it matches the latest version, we'll use 'current' instead.

If no version is specified via props, assume 'current'.

Test Plan

On react-native-website repo, after installing a version of Docusaurus with this patch applied:

  1. Check http://localhost:3000/react-native/docs/getting-started.html (AKA 0.53-RC), confirm 'current' tag is used in script block
  2. Check http://localhost:3000/react-native/docs/next/getting-started.html (AKA master), confirm 'next' tag is used in script block
  3. Check http://localhost:3000/react-native/docs/0.52/getting-started.html (AKA 0.52), confirm '0.52' tag is used in script block

Script block above refers to the block where DocSearch is configured at the end of the HTML body, as such:

<script>
  var search = docsearch({
    apiKey: '2c98749b4a1e588efec53b2acec13025',
    indexName: 'react-native-versions',
    inputSelector: '#search_input_react',
    algoliaOptions: {"facetFilters":["tags:current"],"hitsPerPage":5}
  });
</script>

If the site is versioned, and the latest version is displayed, the URL will not change. We need to let Algolia know this is the case.
@JoelMarcey
Copy link
Contributor

@hramos Thanks for fixing this!

@JoelMarcey
Copy link
Contributor

We should probably update the versioning and/or search docs to mention this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants