dillonzq / LoveIt

❤️A clean, elegant but advanced blog theme for Hugo 一个简洁、优雅且高效的 Hugo 主题
https://hugoloveit.com
MIT License
3.37k stars 1.07k forks source link

[FEATURE] Provide algolia docsearch #481

Open vidhya03 opened 4 years ago

vidhya03 commented 4 years ago

Describe the feature you want 描述你的功能需求

Currently the search support for algolia, needs to be added by exporting index.json https://hugoloveit.com/theme-documentation-basics/#52-search-configuration

how ever new algolia docsearch added recently , which will automatically crawler the website and add search index automatically

Useful reference 有价值的参考


<!-- at the end of the HEAD -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

<!-- at the end of the BODY -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>

<script type="text/javascript">
 docsearch({
apiKey: 'd672449370ed94b6bb27a0ad6de65a60',
indexName: 'hugoloveit',
inputSelector: '### REPLACE ME ####',
algoliaOptions: { 'facetFilters': ["lang:$LANG"] },
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>

For example if you want to refine the search to the lang "en" just specify: 'facetFilters': ["lang:en"]

If available, provide useful links to fulfill the feature. 如果可以的话, 提供实现这个功能的相关参考链接.

bitog commented 4 years ago

Great idea. Do you mind doing a pull request @vidhya03?

vidhya03 commented 4 years ago

@dducted James, i just started hugo, it take time for me to do.

mxxws commented 4 years ago

author may be have something to do , so u can try other theme.