Skip to content

Commit

Permalink
Add Set Algolia Env
Browse files Browse the repository at this point in the history
Closes gh-26
  • Loading branch information
rwinch committed Apr 17, 2024
1 parent 464d9ec commit b5ea8ab
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ IMPORTANT: Be sure to register this extension under the `antora.extensions` key
This extension applies the recommended Antora Extensions.
It applies the following extensions in the proper order:

* <<Set Algolia Env>>
* <<Partial Build>>
* https://gitlab.com/antora/antora-atlas-extension[@antora/atlas-extension]
* <<Latest Version>>
Expand All @@ -77,6 +78,14 @@ antora:
root_component_name: 'security'
----

=== Set Algolia Env

*require name:* @springio/antora-extensions/set-algolia-env-extension

IMPORTANT: Be sure to register this extension under the `antora.extensions` key in the playbook, not the `asciidoc.extensions` key!

This extension sets the Algolia environment variables to enable search.

=== Collector Cache Config
*require name:* @springio/antora-extensions/inject-collector-cache-config-extension

Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { name: packageName } = require('#package')

module.exports.register = function ({ playbook, config }) {
this.require(`${packageName}/set-algolia-env-extension`).register.call(this, { playbook, config })
this.require(`${packageName}/partial-build-extension`).register.call(this, { playbook, config })
this.require('@antora/atlas-extension').register.call(this, { config })
this.require(`${packageName}/latest-version-extension`).register.call(this, { config })
Expand Down
7 changes: 7 additions & 0 deletions lib/set-algolia-env-extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

module.exports.register = function () {
process.env.ALGOLIA_API_KEY = '9d489079e5ec46dbb238909fee5c9c29'
process.env.ALGOLIA_APP_ID = 'WB1FQYI187'
process.env.ALGOLIA_INDEX_NAME = 'springdocs'
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"./tabs-migration-extension": "./lib/tabs-migration-extension.js",
"./static-page-extension": "./lib/static-page-extension.js",
"./cache-scandir": "./lib/cache-scandir/index.js",
"./set-algolia-env-extension": "./lib/set-algolia-env-extension.js",
"./static-pages/search": "./lib/static/search.adoc",
"./static-pages/spring-projects": "./lib/static/spring-projects.adoc",
"./asciinema-extension": "./lib/asciinema-extension.js"
Expand Down
1 change: 1 addition & 0 deletions test/extensions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('extensions', () => {
it('should be able to call register function exported by extension', () => {
ext.register.call(generatorContext, {})
expect(generatorContext.required).eql([
`${packageName}/set-algolia-env-extension`,
`${packageName}/partial-build-extension`,
'@antora/atlas-extension',
`${packageName}/latest-version-extension`,
Expand Down
23 changes: 23 additions & 0 deletions test/set-algolia-env-extension-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-env mocha */
'use strict'

const { expect } = require('./harness')
const { name: packageName } = require('#package')

describe('extensions', () => {
const ext = require(packageName + '/set-algolia-env-extension')

describe('bootstrap', () => {
it('should be able to require extension', () => {
expect(ext).to.be.instanceOf(Object)
expect(ext.register).to.be.instanceOf(Function)
})

it('should be able to call register function exported by extension', () => {
ext.register.call()
expect(process.env.ALGOLIA_API_KEY).to.eql('9d489079e5ec46dbb238909fee5c9c29')
expect(process.env.ALGOLIA_APP_ID).to.eql('WB1FQYI187')
expect(process.env.ALGOLIA_INDEX_NAME).to.eql('springdocs')
})
})
})

0 comments on commit b5ea8ab

Please sign in to comment.