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

[WIP] Integrate Agolia Search #691

Closed
wants to merge 3 commits into from
Closed

Conversation

marvinchin
Copy link
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] New feature

Resolves #656.

What is the rationale for this request?
Allow users to integrate Agolia search with their site

What changes did you make? (Give an overview)

  • Streamline search related configs
  • Add support for Agolia search

Testing instructions:
For the se-book repository:

Update site.json:

{
    // ... some config
    "search": {
        "provider": "agolia",
        "config": {
            "apiKey": API_KEY_HERE,
            "indexName": INDEX_NAME
        }
    }
}

Update navigation.md:

...
      <searchbar placeholder="Search" agolia menu-align-right></searchbar>
...

Agolia search results should be displayed when user enters query in search bar.

@acjh
Copy link
Contributor

acjh commented Feb 13, 2019

Is it possible to improve plugin support such that this can be implemented as a plugin?

It feels odd to integrate an optional third-party service to such an extent in MarkBind.

If necessary, then it can be done in a separate PR.

@marvinchin
Copy link
Contributor Author

marvinchin commented Feb 13, 2019

That might be possible. I'm thinking of extending the plugin support to allow adding scripts and stylesheets in the preRender stage (through some helper methods e.g. addExternalScript, addExternalStylesheet, addRawScript).

Alternatively, we could just modify the DOM directly as part of the postRender (no additional support needed), but I feel that this might be a little less clean.

What are your thoughts on this?

@acjh
Copy link
Contributor

acjh commented Feb 13, 2019

I'm thinking of extending the plugin support to allow adding scripts and stylesheets in the preRender stage (through some helper methods e.g. addExternalScript, addExternalStylesheet, addRawScript).

Those are independent of the content right? They can be functions at the same level as preRender.
We should try to handle this using page.ejs.

We can accept raw HTML to be more flexible, then we just need addScript and addStylesheet.

Alternatively, we could just modify the DOM directly as part of the postRender (no additional support needed), but I feel that this might be a little less clean.

Agreed, don't do this.

@marvinchin
Copy link
Contributor Author

I'm concerned that having to write

addStylesheet("<link rel="stylesheet" href="STYLESHEET_LINK">");

would be clunky compared to something like

addExternalStylesheet("STYLESHEET_LINK");

There might be more methods available (which might be a little more confusing), but I wonder if it is worth the tradeoff for a more pleasant syntax.

@acjh
Copy link
Contributor

acjh commented Feb 13, 2019

There is more to a <link> and a <script> than that:

It is better to be flexible for plugin authors.
Examples of templating scripts in other programming languages (didn't find a good JS example):

Plugin can also load HTML file of styles and/or scripts and pass it as string.

@marvinchin
Copy link
Contributor Author

Alright, will do that instead then! 🙂

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.

None yet

2 participants