Coder Social home page Coder Social logo

meilisearch / docs-searchbar.js Goto Github PK

View Code? Open in Web Editor NEW
161.0 161.0 31.0 5.09 MB

Front-end search bar for documentation with Meilisearch

Home Page: https://www.meilisearch.com/

License: MIT License

JavaScript 77.85% Shell 2.08% HTML 1.47% SCSS 18.60%
integration meilisearch search-bar

docs-searchbar.js's Introduction

Meilisearch

DEPRECATED - docs-searchbar.js


🚨 DEPRECATION WARNING 🚨

Dear Community,

We'd like to share some updates regarding the future maintenance of this repository:

Our team is small, and our availability will be reduced in the upcoming times. As such, we decided to deprecate this repository. We invite you into using Tauri's meilisearch-docsearch instead of this one.

We still accept bug fixes from the community but no more enhancements.

Seeking immediate support? Please join us on our Discord channel.


NPM version Test License Bors enabled

docs-searchbar.js is a front-end SDK for Meilisearch providing a search bar for your documentation.

docs-searchbar.js comes with a css template. The default styling of this library fits a documentation search bar, but you can customize it.

To make it work, You need to have your documentation's content in a Meilisearch instance. If not already the case, you can achieve this using docs-scraper.

Meilisearch is an open-source search engine. Discover what Meilisearch is!

docs-searchbar.js example

πŸ’‘ If you use VuePress for your website, you should check out our VuePress plugin for Meilisearch.

Table of Contents

⚑ Supercharge your Meilisearch experience

Say goodbye to server deployment and manual updates with Meilisearch Cloud. Get started with a 14-day free trial! No credit card required.

πŸ”§ Installation

With npm:

We only guarantee that the package works with node >= 12 and node < 15.

# With NPM
npm install docs-searchbar.js
# With Yarn
yarn add docs-searchbar.js

In your HTML:

Add the following script into your HTML file:

<script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.js"></script>

πŸƒβ€β™€οΈ Run Meilisearch

There are many easy ways to download and run a Meilisearch instance.

For example, using the curl command in your Terminal:

# Install Meilisearch
curl -L https://install.meilisearch.com | sh

# Launch Meilisearch
./meilisearch --master-key=masterKey

NB: you can also download Meilisearch from Homebrew or APT or even run it using Docker.

Index your data

The goal of this library is to provide a front-end search bar into your own documentation. To make that possible, you need to gather your website content in advance, and index it in a Meilisearch instance.

Luckily, we provide all the tools that you need, and can help you through the whole process, if you follow this guide πŸš€

Note: If you want to try out docs-searchbar.js as a first introduction, try out our playground.

Use your own scraper

We recommend using the docs-scraper tool to scrape your website, but this is not mandatory.

If you already have your own scraper but you still want to use Meilisearch and docs-searchbar.js, check out this discussion.

🎬 Getting Started

ES module

Add an input tag with the attribute id="search-bar-input in one of your HTML file.

<input type="search" id="search-bar-input" />

Then, import docs-searchbar.js and run the docsSearchBar function. For more explaination of the required parameters, see next section.

import docsSearchBar from 'docs-searchbar.js'

docsSearchBar({
  hostUrl: 'https://mymeilisearch.com',
  apiKey: 'XXX',
  indexUid: 'docs',
  inputSelector: '#search-bar-input',
})

HTML

Add the following code to one of your HTML files.

<!DOCTYPE html>
<html>
  <head>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.css"
    />
  </head>

  <body>
    <input type="search" id="search-bar-input" />
    <script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.js"></script>
    <script>
      docsSearchBar({
        hostUrl: 'https://mymeilisearch.com',
        apiKey: 'XXX',
        indexUid: 'docs',
        inputSelector: '#search-bar-input',
        debug: true, // Set debug to true if you want to inspect the dropdown
      })
    </script>
  </body>
</html>

The hostUrl and the apiKey (optional) fields are the credentials of your Meilisearch instance.
indexUid is the index identifier in your Meilisearch instance in which your website content is stored.
inputSelector is the id attribute of the HTML search input tag. As an alternative the dom element can be supplied with inputElement directly.

Your documentation content is not indexed yet? Check out this tutorial.

WARNING: We recommend providing the Meilisearch public key, which is enough to perform search requests.
Read more about Meilisearch authentication.

Styling

docs-searchbar.js comes with a css template. It has to be added in your project in the following way:

In an ES+ environment:

import 'docs-searchbar.js/dist/cdn/docs-searchbar.css'

In a HTML file, the link tag should be added in your header:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.css"
/>

🎨 Customization

The default behavior of this library fits perfectly for a documentation search bar, but you might need some customizations.

Optional parameters

When calling the docsSearchBar method, you can add optional fields:

queryHook

queryHook takes a callback function as value. This function will be called on every keystroke to transform the typed keywords before querying Meilisearch. By default, it does not do anything, but it is the perfect place for you to add some preprocessing or custom functionality.

transformData

transformData takes a callback function as value. This function will be called on every hit before displaying them. By default, it does not do anything, but it lets you add any post-processing around the data you received from Meilisearch.

handleSelected

handleSelected takes a callback function a value. This function is called when a suggestion is selected (either from a click or a keystroke). By default, it displays anchor links to the results page. Here is an example to override this behavior:

docsSearchBar({
  // ...
  handleSelected: function (input, event, suggestion, datasetNumber, context) {
    // Prevents the default behavior on click and rather opens the suggestion
    // in a new tab.
    if (context.selectionMethod === 'click') {
      input.setVal('')

      const windowReference = window.open(suggestion.url, '_blank')
      windowReference.focus()
    }
  },
})

Note that, by default, you can already open a new tab thanks to the CMD/CTRL + Click action.

The function is called with the following arguments:

  • input: a reference to the search input element. It comes with the .open(), .close(), .getVal() and .setVal() methods.

  • event: the actual event triggering the selection.

  • suggestion: the object representing the current selection. It contains a .url key representing the destination.

  • datasetNumber: this should always be equal to 1 as docs-searchbar.js is searching into one dataset at a time. You can ignore this attribute.

  • context: additional information about the selection. Contains a .selectionMethod key that can be either click, enterKey, tabKey or blur, depending on how the suggestion was selected.

meilisearchOptions

You can forward search parameters to the Meilisearch API by using the meilisearchOptions key. Checkout out the Meilisearch documentation about search parameters.

For example, you might want to increase the number of results displayed in the dropdown:

docsSearchBar({
  meilisearchOptions: {
    limit: 10,
  },
})

enableDarkMode

Allows you to display the searchbar in dark mode. It is useful if your website has dark mode support and you also want the searchbar to appear in a dark version. You can always edit the style of the searchbar to match the style of your website. When the option enableDarkMode is set to auto, the searchbar automatically sets the mode to the system mode.

enableDarkMode has three possible states:

  • false: enforce light mode.
  • true: enforce dark mode.
  • auto: system mode (light or dark).

Example:

docsSearchBar({
  ...
  enableDarkMode: 'auto'
})

Dark mode with enableDarkMode set to auto and system mode set to dark:

docs-searchbar with dark mode

enhancedSearchInput

When set to true, a theme is applied to the search box to improve its appearance. It adds the .searchbox class which can be used to further customise the search box.

Example:

docsSearchBar({
  ...
  enhancedSearchInput: true
})
More Examples

Here is a basic HTML file used in the playground of this repository.

As a more concrete example, you can check out the configuration applied in the Meilisearch plugin for VuePress.

Styling

/* Main dropdown wrapper */
.meilisearch-autocomplete .dsb-dropdown-menu {
  width: 500px;
}

/* Main category */
.meilisearch-autocomplete .docs-searchbar-suggestion--category-header {
  color: darkgray;
  border: 1px solid gray;
}

/* Category */
.meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-column {
  color: gray;
}

/* Title */
.meilisearch-autocomplete .docs-searchbar-suggestion--title {
  font-weight: bold;
  color: black;
}

/* Description */
.meilisearch-autocomplete .docs-searchbar-suggestion--text {
  font-size: 0.8rem;
  color: gray;
}

/* Highlighted text */
.meilisearch-autocomplete .docs-searchbar-suggestion--highlight {
  color: blue;
}

TIPS: When inspecting the dropdown markup with your browser tools, you should add debug: true to your docsSearchBar call to prevent it from closing on inspection.

More Examples

Here is the CSS customization applied in the Meilisearch plugin for VuePress.

πŸ€– Compatibility with Meilisearch

This package guarantees compatibility with version v1.x of Meilisearch, but some features may not be present. Please check the issues for more info.

βš™οΈ Development Workflow and Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!

πŸ₯‡ Credits

Based on Algolia DocSearch repository from this commit.
Due to a lot of future changes in this repository compared to the original one, we don't maintain it as an official fork.


Meilisearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

docs-searchbar.js's People

Contributors

ayushk-101 avatar bidoubiwa avatar bors[bot] avatar brunoocasali avatar colinfrick avatar curquiza avatar dependabot-preview[bot] avatar dependabot[bot] avatar devcer avatar dichotommy avatar hirohe avatar lorenzosapora avatar mdubus avatar meili-bors[bot] avatar meili-bot avatar qdequele avatar techspiritss avatar thelaw1337 avatar vird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docs-searchbar.js's Issues

Use Meili's logo in dropdown footer

Currently, the footer of the dropdown is a simple "Powered by MeiliSearch".
It could be cool to improve this footer with a logo.

Do not forget to link the logo to the landing page ;)

Project not compatible with node 16

Description
Node 16 is now the latest version of node. It is not the active version yet so we should not pro-actively solve this issue. Nonetheless the 26 octobre 2021 it will become the active version.

See node releases status

As for now, this project is not compatible with node 16 because of node-sass.

Current behavior
Node-sass v4 is not compatible with node 16. We should upgrade to v6

See related documentation

Environment (please complete the following information):

  • OS: IOS
  • MeiliSearch version: v.0.20.0
  • docs-searchbar.js version: v1.1.11

Allow the docs-searchbar to be invoked using keyboard shortcut

Description
The idea is to allow users to invoke the Meilisearch frontend search bar using a keyboard shortcut like cmd + K. A keyboard shortcut implementation to invoke the search bar is already present in the Algolia search bar and also Slack search bar and it makes it easier for users to do a search rather than have to go to the search bar in the navigation bar every time.

Basic example
The user can invoke the search by using a keyboard shortcut.
Algolia's implementation for reference:
image
image

Should we remove the ".lock" file?

We are thinking about removing (or not) the .lock file of this package.

Since this discussion concerns all the JS tools of the MeiliSearch organization, we created a centralized issue: meilisearch/integration-guides#53.

If you are interested in this topic, please read it and feel free to share your (professional or not) experience with us on this main issue. Every opinion would be really helpful! 😁

Text in backticks does not appear in search results

Observation:

  • Text in backticks that is a heading show ups in search results
  • Text in backticks that is regular text or in tables does not
  1. createdAt:
  • The first result is a heading: /reference/api/keys.md#key-object
  • createdAt from /reference/api/indexes.md#index-object does not appear

Screen Shot 2022-09-26 at 14 26 42

  1. uid
  • Only shows uids that are headings:
    • /reference/api/keys.md#uidο»Ώ
    • /reference/api/tasks.md#uid
    • uid is used in the /reference/api/indexes.md#index-object table and almost every β€œPath parameters” table, but these are not part of the search results

Screen Shot 2022-09-26 at 14 46 29

  1. databaseSize
    Only used in the /reference/api/stats.md#stats-object table but this table is not in the results

Screen Shot 2022-09-26 at 14 53 28

React based SDK

Are there any plans to make this based on a react with possibly some API exposed for tweaking it, so anyone can customize it as and how they want, using components based UI etc etc?

How to get grouped data

I have integrated Meilisearch. I scraped our markdown documentation myself. I have integrated docs-searchbar.js.
But, when I query my output is not "grouped" (like an SQL "group by")
Did I miss something in the scraping or is there something else I need to do?
My output:
image
But I want it to "group" like this:
image
my data looks like this:

  {
    "objectID": 133,
    "hierarchy_lvl0": "Contribution Guide",
    "hierarchy_lvl1": "Contribution Guide",
    "hierarchy_lvl2": "Helping to Resolve Existing Issues",
    "hierarchy_lvl3": null,
    "hierarchy_lvl4": "Testing Patches",
    "hierarchy_lvl5": null,
    "hierarchy_lvl6": null,
    "content": "You can also help out by examining pull requests that have been submitted to Quasar via GitHub. In order to apply someone's changes, you need to first create a dedicated branch: bash $ git checkout -b testing_branch Then, you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to a topic branch \"orange\" located at https://github.com/JohnSmith/quasar. bash $ git remote add JohnSmith https://github.com/JohnSmith/quasar.git $ git pull JohnSmith orange After applying their branch, test it out! Here are some things to think about: Does the change actually work? Does it have the proper documentation coverage? Should documentation elsewhere be updated? Do you like the implementation? Can you think of a nicer or faster way to implement a part of their change? Once you're happy that the pull request contains a good change, comment on the GitHub issue indicating your approval. Your comment should indicate that you like the change and what you like about it. Something like:  Example pull request comment I like the way you've restructured the code in card.vue - much nicer. Documentation is updated too.  If your comment simply reads \"+1\", then odds are that other reviewers aren't going to take it too seriously. Show that you took the time to review the pull request.",
    "anchor": "Testing-Patches",
    "url": "/contribution-guide/contribution-guide"
  },

As you can see, I have removed the hierarchy_radio_lvlX fields as I haven't figured out how they are to be used, so far.

Any help, suggestions, comments are welcomed. Thank you for your time and wonderful package.

function `checkArguments` only checks a few arguments

The checkArguments function receives the following parameters :

    hostUrl,
    apiKey,
    indexUid,
    inputSelector,
    debug,
    meilisearchOptions,
    queryDataCallback,
    autocompleteOptions,
    transformData,
    queryHook,
    handleSelected,
    enhancedSearchInput,
    layout

But it only checks:

  • that apiKey, indexUid, and hostUrl are present
  • that inputSelector is a string
  • that there is an input in the page with inputSelector as CSS selector

All the other checks are missing. Maybe we should add them to have a more robust library.

Confirm compatibility with node 16

Description
Node 16 is now the latest version of node. It is not the active version yet so we should not proactively confirm compatibility with node 16. Nonetheless, the 26 October 2021 node 16 will become the active version and this is a reminder for that we have to guarantee compatibility.

See node releases status

Environment (please complete the following information):

  • OS: IOS
  • MeiliSearch version: v.0.20.0
  • docs-searchbar.js version: v1.1.11

Scroll issue on Firefox 74.0

Someone reported an issue on Firefox 74.0 (Ubuntu):

Selection_001

The scroll is activated and we do not see the MeiliSearch logo anymore.

Usage on README

Currently, we don't know how to use docs-searchbar.js

  • Add usage
  • Add examples
  • Add details about options that we can pass to docsSearchBar function
  • Add details about how to customize the CSS

Remove warning during the build

$ yarn
[...]
$ yarn build
[...]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
[...]

Automatic dark/light mode toggle

As for now when the theme mode is changed on the system, docs-searchbar needs a reload to apply changes.

When adding this in the code:

@media (prefers-color-scheme: dark) { 
  div[data-ds-theme='dark'] {
    @if ($searchbox == true) {
      @include searchbox($searchbox-config-dark...);
    }
    @include dropdown($dropdown-config-dark...);
  }
}

the issue is resolved but introduces another problem. The user that integrates docs-searchbar.js might want to force data-ds-theme=dark without having the preferes-color-scheme to dark.

A solution must be find to answer all situations:

  • Automatic toggling when theme is changed on system
  • Forcing dark mode should be possible

Upgrade jest dependency

Currently, we cannot upgrade jest on this package because pass from the v23 to the v24 is breakable for our tests suite.

See #79.

If someone is ok to upgrade our tests and the jest dependency, that would be really appreciated πŸ™‚

Change master branch to main

Let's be allies and make this change that means a lot.

Here is a blog post that explain a little more why it's important, and how to easily do it. It will be a bit more complicated with automation, but we still should do it!

Add browser tests

Testing

With the same method used in meilisearch-js we should add a very simple test that tries out the search bar in doc-searchbar.js

How

As mvp we should add at least one test that does the following

  1. Go the served webpage and check if it loads correctly
  2. Using a library like puppeteer we should manipulate the DOM the following way.
    • Focus on the input
    • Change its value to a given search query, by mimicking typing behavior
    • Check for a dynamically created DOM element containing search results
    • Ensure this DOM element is not empty

Why

With these tests we check for two possible problems:

  • Testing front-end webpage still works correctly, thus confirming that any fail will not come from the test itself
  • Testing that DocSearchBar still works correctly when using a remote dataset that follows its requirements

Make docs-searchbar compatible with typescript

For the moment when using docs-searchbar.js in an typescript environment, it raises an error because of a lack of declaration file. This can be prevented by providing a type file.

Better explanation on the issue here.

Upgrade to jest v24-26 and babel to version 7

Because or Jest version is v23 we have vulnerabilities caused by yargs-parser.
We tried to fix it by using the resolutions, this introduced more problems. Also, resolutions are patches and not a solution.

linked issue: jestjs/jest#7424

This vulnerability has been fixed in jest v24>

Jest version 24 uses Babel 7:
https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#typescript-support

But we use a previous version that is not compatible with jest v24.

To fix this problem properly we should consider upgrading jest to v24 or higher and babel to version 7.

Autocomplete options

When passing an autocompleteOptions to the docsSearchBar function, a second input (HTML tag) is popping.
The autocompleteOptions are indeed not well passed in the autocomplete method.

Remove use of `!important` in CSS

There are !important in CSS. This is a bad practice and it would be nice to remove them.
If so, we have to be careful that it might be breaking.

Capture d’écran 2021-06-07 aΜ€ 16 22 40

Add browser tests

Testing

With the same method used in meilisearch-js we should add a very simple test that tries out the search bar in doc-searchbar.js

How

As mvp we should add at least one test that does the following

  1. Go the served webpage and check if it loads correctly
  2. Using a library like puppeteer we should manipulate the DOM the following way.
    • Focus on the input
    • Change its value to a given search query, by mimicking typing behavior
    • Check for a dynamically created DOM element containing search results
    • Ensure this DOM element is not empty

Why

With these tests we check for two possible problems:

  • Testing front-end webpage still works correctly, thus confirming that any fail will not come from the test itself
  • Testing that DocSearchBar still works correctly when using a remote dataset that follows its requirements

Remove support for node 12 and ensure support for node 18

Node version compatibilities should be changed in the tests and the readme.

See related issue.

Previous ensured compatibilities:

  • Node 12
  • Node 13
  • Node 14

New compatibilities to ensure:

  • Node 14
  • Node 16
  • Node 18

TODO:

  • Update requirements/compatibilities in README.md.
  • Update node versions tested in CI tests.

Cypress tests should not work with a remote MeiliSearch instance

Maybe I'm wrong and the Cypress tests are not working with a remote MeiliSearch instance, but it looks like they are using the https://docs-search-bar.meiliseasrch.com instance, which is not recommended. This remote instance is indeed the MeiliSearch instance used by the documentation to provide a search bar. It's not an easy task to upgrade this instance since it's very impactful for the users of the docs. Our CI should definitely not rely on this instance.

Plus, it's not convenient at all to update a remote instance to make CI tests work. A CI should be as independent as possible.
We should download locally (in the CI) a MeiliSearch that will be used for the cypress tests πŸ™‚

Remove dupicated version mention

Version are both changed in package.json and version.js.

Creating a duplication of changes in each release. version.js is used by src/lib/main.js

import toFactory from 'to-factory'
import DocsSearchBar from './DocsSearchBar'
import version from './version'

We should find a solution to avoid this duplication

Hotkey / does not work

The autocomplete.js library does not recognize the / character as hotkey. You must pass 191 instead of '/' to get it worked.

The docs-searchbar.js should check the user input in autocompleteOptions.keyboardShortcuts: if there is a / it should replace it by 191 so that autocomplete.js can take it into account.

Create environment where dark mode can be disabled or enabled

Description
As from this PR #340 when dark mode is set on OS it will automatically change the docs-searchbar.js to a dark mode. Disabling this is quite painful.

Dark mode in OS is not always the mode you want on your apps.

Solution

We should wrap the modes into classes in order to make them toggable. For example, using the solution suggested here

MeiliSearchCommunicationError

Hey guys, I meet a problem when I use meilisearch-js.

In the old version, It works great. But yesterday, I did some refactor(nothing to do with meilisearch-js) and then, after I deployed my website, I found I can't use the search service.I've send request with masterKey. But problem is still here.

docs-searchbar.min.js:2 Uncaught (in promise) MeiliSearchCommunicationError: request to https://trantor-meilisearch.app.terminus.io/indexes/trantor/search failed, reason: connect ECONNREFUSED
    at t.<anonymous> (docs-searchbar.min.js:2:67933)
    at docs-searchbar.min.js:2:64772
    at Object.next (docs-searchbar.min.js:2:64877)
    at docs-searchbar.min.js:2:63815
    at new Promise (<anonymous>)
    at r (docs-searchbar.min.js:2:63563)
    at t.request (docs-searchbar.min.js:2:67624)
    at t.<anonymous> (docs-searchbar.min.js:2:68597)
    at docs-searchbar.min.js:2:64772
    at Object.next (docs-searchbar.min.js:2:64877)

and this is the code in my project

componentDidMount() {
  window.docsSearchBar({
    hostUrl: 'https://trantor-meilisearch.app.terminus.io/',
    apiKey: '',
    indexUid: 'trantor',
    inputSelector: '#search-input',
    meilisearchOptions: { limit: 99, matches: true }
  }, { limit: 50000 })
}

You can reproduce the problem in https://trantor-doc-test-mobile.app.terminus.io/v1.0.x/doc/quick-start/base-trantor

Add dark-mode

Dark mode is not enabled on the code and does not switch if implemented on another website.

something is empty in search resultlist

Description

The search drop-down box does not display the content correctly.

Expected behavior

It should be like this:

image

Current behavior

vuepress

image

docs-searchbar.js

image

Screenshots or Logs
If applicable, add screenshots or logs to help explain your problem.

  1. During the search, data was retrieved but not displayed
    image

  2. At first I thought it was my data problem, but I had the same problem using docs-scraper to grab docs.meilisearch.com documents.

docker code :

docker run -it --rm \
  --network=host \
  -e MEILISEARCH_HOST_URL=http://127.0.0.1:7700 \
  -e MEILISEARCH_API_KEY=zxczxc\
  -v /root/meilisearch/docs-scraper-config2.json:/docs-scraper/config.json \
  getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json

config:

{
    "index_uid": "docs",
    "sitemap_urls": ["https://docs.meilisearch.com/sitemap.xml"],
    "start_urls": ["https://docs.meilisearch.com"],
    "selectors": {
      "lvl0": {
        "selector": ".sidebar-heading.open",
        "global": true,
        "default_value": "Documentation"
      },
      "lvl1": ".theme-default-content h1",
      "lvl2": ".theme-default-content h2",
      "lvl3": ".theme-default-content h3",
      "lvl4": ".theme-default-content h4",
      "lvl5": ".theme-default-content h5",
      "text": ".theme-default-content p, .theme-default-content li"
    },
    "strip_chars": " .,;:#",
    "scrap_start_urls": true,
    "custom_settings": {
      "synonyms": {
        "relevancy": ["relevant", "relevance"],
        "relevant": ["relevancy", "relevance"],
        "relevance": ["relevancy", "relevant"]
      }
    }
}

Environment (please complete the following information):

  • OS: [ Linux CentOS]
  • MeiliSearch version: [docker last v.0.22.0]
  • docs-scraper version: [docker last 815baa3fc4fd v.0.10.5]
  • docs-searchbar.js version: [v1.1.11 ~ v1.3.2]
  • Browser: [Chrome version 93.0.4577.82] [Microsoft Edge 93.0.961.52]

Using docs-searchbar.js library without using docs-scraper tool

Here is the question from one of our users on Slack:

Hey guys - if I want to use the awesome search bar at https://github.com/meilisearch/docs-searchbar.js but don't use the scraper (I'm pushing content via API calls), how do I address the "Object has no key lvl0" error? What metadata do I need to push?

The scraper: https://github.com/meilisearch/docs-scraper
Related tutorial: https://docs.meilisearch.com/resources/howtos/search_bar_for_docs.html

Changes after the Node.js v10 EOL (2021-04-30)

Related meilisearch/meilisearch-js#760

Node 10 is the end of life since April 2021. It becomes more and more unsupported by the libraries we use in our different JS project. Until now we had to make a workaround to keep compatibility with node 10.

As for the official EOL of node, we should also drop support for node 10 and stay up-to-date with the libraries that upgraded without node 10 support.

We need to:

  • Remove the tests with node.js v10 in the CIs
  • Ensure no library has been blocked to avoid losing node 10 compatibility

Fix security vulnerability by updating jest

Currently, the version of jest is 23.6.0 and the most recent one is v0.26.4.
This delay of version leads to security vulnerability because jest depends on jest-cli that depends on an old version of yargs that depends on an old version of yargs-parser (below v0.13.2, that is recommended to fix the vulnerability).

But updating jest leads to this error when running yarn test:
Capture d’écran 2020-09-07 aΜ€ 12 59 57

We should update jest to the latest major version.

Add a configuration to display searchbar in a modal

Description
It would be really nice to be able to display the search bar in a modal similar to the way Algolia does it. Then we could add multiple buttons on the site to trigger the search modal via events

Basic example
Screen Shot 2022-07-07 at 11 01 53 AM

Use Meili's style and main color

It might be cool to use the Meili's color and a better style (if you are inspired) for our own dropdown.

All the files are:

  • in src/styles/*.scss for the CSS
  • in src/lib/templates.js for the html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.