Skip to content

Commit

Permalink
fix(template): fix import docsearch error (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
luxiaobei committed Nov 3, 2021
1 parent caf7724 commit 9492006
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions packages/core/src/site-template/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,3 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

(window as any).global = window;

(window as any).process = {
env: { DEBUG: undefined }
};
11 changes: 9 additions & 2 deletions packages/template/src/services/search.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Inject, Injectable } from '@angular/core';
import { GlobalContext } from './global-context';
import docsearch from 'docsearch.js';
import { DOCUMENT } from '@angular/common';
import { fromEvent, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -34,7 +33,7 @@ export class SearchService {
}
}

private initAlgolia(searchSelector: string) {
private async initAlgolia(searchSelector: string) {
const algolia = this.global.config.algolia.appId
? {
appId: this.global.config.algolia.appId,
Expand All @@ -46,6 +45,14 @@ export class SearchService {
indexName: this.global.config.algolia.indexName
};

(window as any).global = window;

(window as any).process = {
env: { DEBUG: undefined }
};

const { default: docsearch } = await import('docsearch.js');

docsearch({
...algolia,
inputSelector: searchSelector,
Expand Down

0 comments on commit 9492006

Please sign in to comment.