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

Limit Algolia Search to Certain Projects or Doc Types #24

Open
ceolson01 opened this issue Mar 7, 2019 · 0 comments
Open

Limit Algolia Search to Certain Projects or Doc Types #24

ceolson01 opened this issue Mar 7, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ceolson01
Copy link
Contributor

ceolson01 commented Mar 7, 2019

Issue at Hand

To accommodate for multiple searches (i.e. one for docs, one for tutorials), we'll need a way to filter a search query's results to only include one particular source.

Proposed Solution

  1. Update Algolia docsearch Config File
  2. Filter by Tags in Search Component

1. Update Algolia docsearch Config File

Our current config file currently includes an entry point for each project's doc section, each with a tags property:

{
  "start_urls": [
    {
      "url": "https://docs.colony.io/colonynetwork/docs-colony/",
      "tags": [
        "colonynetwork"
      ]
    },
    {
      "url": "https://docs.colony.io/colonynetwork/",
      "tags": [
        "colonynetwork"
      ]
    },
    ...
  ],
  ...
}

With tutorials added, it may be good to add a docs tag to each relevant docs url, and a tuts or tutorials tag to each relevant project's tutorials url:

{
  "start_urls": [
    {
      "url": "https://docs.colony.io/colonynetwork/docs-colony/",
      "tags": [
        "colonynetwork",
        "docs"
      ]
    },
    {
      "url": "https://docs.colony.io/colonynetwork/tutorial-first-steps/",
      "tags": [
        "colonynetwork",
        "tutorials"
      ]
    },
    {
      "url": "https://docs.colony.io/colonynetwork/",
      "tags": [
        "colonynetwork",
      ]
    },
    ...
  ],
  ...
}

2. Filter by Tags in Search Component

Algolia's docsearch accepts an algoliaOptions object which you can learn more about here. It accepts these API parameters.

Ideally, the filters should be Search component props, but in it's simplest form, this could look something like:

// Search tutorials only
docsearch({
  algoliaOptions: {
    filters: 'tags:tutorials',
  },
  ...
});

// Search only colonyNetwork docs
docsearch({
  algoliaOptions: {
    filters: 'tags:colonynetwork AND tags:docs',
  },
  ...
});
@ceolson01 ceolson01 added the enhancement New feature or request label Mar 7, 2019
@ceolson01 ceolson01 added this to the Sprint 22 milestone Mar 18, 2019
@ceolson01 ceolson01 self-assigned this Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant