Skip to content

Commit

Permalink
feat: provide an indexing API key from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Parisot committed Dec 9, 2018
1 parent 830ef22 commit fd5ae30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ hexo.extend.console.register(
'Index your content in Algolia Search API',
{
options: [
{ name: '--dry-run', desc: 'Does not push content to Algolia' },
{
name: '--dry-run',
desc: 'Does not push content to Algolia (default: false).'
},
{
name: '--flush',
desc: 'Resets the Algolia index before starting the indexation'
desc: 'Resets the Algolia index before starting the indexation (default: false).'
},
{
name: '--layouts',
desc: 'A comma-separated list of page layouts to index (default: "page").',
},
{
name: '--indexing-key',
desc: 'An algolia API key with add/delete records permissions.\n\t\t It should be different than the search-only API key configured in _config.yml.',
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ module.exports = function(args, callback) {
var config = Object.assign({}, hexo.config.algolia);
var indexName = config.indexName;
var applicationID = config.applicationID;
var apiKey = String(process.env.HEXO_ALGOLIA_INDEXING_KEY || '');
var options = Object.assign({}, CONSOLE_DEFAULTS, args || {});
var pageLayouts = options.layouts.split(',');
var apiKey = String(process.env.HEXO_ALGOLIA_INDEXING_KEY || options.indexingKey || '');
var client;
var index;

Expand Down

0 comments on commit fd5ae30

Please # to comment.