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

[proposed enhancement] Algolia - Allow appId in algolia configuration #465

Closed
atroncy opened this issue Feb 20, 2018 · 5 comments
Closed
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.

Comments

@atroncy
Copy link
Contributor

atroncy commented Feb 20, 2018

Is this a bug report?

No

Have you read the Contributing Guidelines?

Yes

Environment

any env

Steps to Reproduce

(Write your steps here:)

  1. Add appId into algolia configuration inside siteConfig.js
  2. appId is ignored during the creation of the docsearch client in lib/core/Site.js

Expected Behavior

I should be able to add my own APP_ID.
According to docsearch-scraper, if you use your own scraper, you should specify to docsearch your APP_ID.
You may want to use your own scraper if you don't want to expose your site to the internet.

Actual Behavior

It's not possible to add your own AppId.
It's take the default one being BH4D9OD16A.

@atroncy atroncy changed the title [proposed enhancement] Algolia - Allow AppId in Algolia Configuration [proposed enhancement] Algolia - Allow appId in algolia configuration Feb 21, 2018
@JoelMarcey JoelMarcey added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. labels Feb 26, 2018
@JoelMarcey
Copy link
Contributor

Hi @atroncy. I do not think that should be too difficult to add. Should just be an if check into siteConfig.js to add to Algolia config.

@juanpicado
Copy link
Contributor

Would it be something like this? or you were thinking about a different approach?

{this.props.config.algolia &&
            (this.props.config.algolia.algoliaOptions ? (
              <script
                dangerouslySetInnerHTML={{
                  __html: `
              var search = docsearch({
                ${this.props.config.algolia.appId ? `appId: ${this.props.config.algolia.appId}` : ''}
                apiKey: '${this.props.config.algolia.apiKey}',
                indexName: '${this.props.config.algolia.indexName}',
                inputSelector: '#search_input_react',
                algoliaOptions: ${JSON.stringify(
                  this.props.config.algolia.algoliaOptions
                )
                  .replace('VERSION', docsVersion)
                  .replace('LANGUAGE', this.props.language)}
              });
            `,
                }}
              />
            ) : (
              <script
                dangerouslySetInnerHTML={{
                  __html: `
              var search = docsearch({
                ${this.props.config.algolia.appId ? `appId: ${this.props.config.algolia.appId}` : ''}
                apiKey: '${this.props.config.algolia.apiKey}',
                indexName: '${this.props.config.algolia.indexName}',
                inputSelector: '#search_input_react'
              });
            `,
                }}
              />
            ))}

@atroncy
Copy link
Contributor Author

atroncy commented Mar 1, 2018

hey thx for the answer
I just issued a new pr for this issue.
It's similar to your solution @juanpicado (with some quote around the props followed by a comma :) )

@juanpicado
Copy link
Contributor

juanpicado commented Mar 2, 2018

It looks good to me, I hope it gets merged soon 💯

@JoelMarcey
Copy link
Contributor

Closed by #481 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.
Projects
None yet
Development

No branches or pull requests

3 participants