diff --git a/fixtures/index.js b/fixtures/index.js index 9cb5cbc3..8463a3f9 100644 --- a/fixtures/index.js +++ b/fixtures/index.js @@ -815,6 +815,36 @@ module.exports.initMocks = function() { 'Strict-Transport-Security', 'max-age=15552000' ]); + nock('https://public-api.wordpress.com:443', {"encodedQueryParams":true}) + .persist() + .get('/rest/v1.1/sites/http%3A%2F%2F127.0.0.1%3A6000') + .reply(200, ["1f8b0800000000000003ad92c14ec3300c865f65f239342b6393e8990b1227244e045569e2d1d03489eaa4434c7d77d2c226c679372bfefdc5f6ef233c3e4055ee3677bb4db9bd67e0648f50810fe8b48c5277c04023a9c18468bccb2991d66bb56d1cae66c12a1abbd2e63dcb5e9e9f72ba8d3154820beeb5ee8ad6f75834d6cff90f8c41aa0eaabdb4840c283533b7c1816ae5938b50dd32b0d2bd9f25b9d0437504a3a15ae70af38504d5eb1b8334d8fc194c0c4643a6b1b96997ac6560a80e831965c433253fedbdb5fe60fea07b8c72465be33a9a0342bbffed9f9601426aac51373298e2e0071d06242a94ef05cf51147c2c8b5270321149f0f30af3a02dda700592e00b8841f014e92ac08524786666718fee4ad8136c217ff67608ea823b9fc27209ffa83fd222b401a669b63e39d5d614654c74e11e612d5534e3c9d3e91be3d7d0b3b8020000"], [ + 'Server', + 'nginx', + 'Date', + 'Mon, 28 Oct 2019 16:03:24 GMT', + 'Content-Type', + 'application/json', + 'Transfer-Encoding', + 'chunked', + 'Connection', + 'close', + 'Vary', + 'Accept-Encoding', + 'X-hacker', + 'Oh, Awesome: Opossum', + 'Expires', + 'Wed, 11 Jan 1984 05:00:00 GMT', + 'Cache-Control', + 'no-cache, must-revalidate, max-age=0', + 'Content-Encoding', + 'gzip', + 'X-ac', + '2.fra _dfw ', + 'Strict-Transport-Security', + 'max-age=15552000' + ]); + nock('https://public-api.wordpress.com:443', {"encodedQueryParams":true}) .persist() .get('/rest/v1.1/sites/http%3A%2F%2F127.0.0.1%3A6000/posts/slug:search') diff --git a/plugins/wp/cms.js b/plugins/wp/cms.js index f9170d74..d2e4653c 100644 --- a/plugins/wp/cms.js +++ b/plugins/wp/cms.js @@ -37,6 +37,10 @@ class CmsModel { async getCategories() { return await this.blog.categoriesList() } + + async getSiteInfo() { + return await this.blog.get() + } } module.exports.CmsModel = CmsModel diff --git a/tests/plugins/wp.test.js b/tests/plugins/wp.test.js index 426d86c6..991a09e1 100644 --- a/tests/plugins/wp.test.js +++ b/tests/plugins/wp.test.js @@ -28,3 +28,11 @@ test('getListOfPosts api works', async t => { t.is(result.length, 2) }) + + +test('getSiteInfo api works', async t => { + + const result = await WPModel.getSiteInfo() + + t.is(result.description, 'Åbne data til dig') +}) diff --git a/themes/opendk/index.js b/themes/opendk/index.js index 21d64ede..11b77bb2 100644 --- a/themes/opendk/index.js +++ b/themes/opendk/index.js @@ -48,8 +48,9 @@ module.exports = function (app) { }) app.get('/', async (req, res, next) => { - // Set up main heading text from config var: - res.locals.home_heading = config.get('HOME_HEADING') || '' + // Set up main heading text from wp: + const siteInfo = await CmsModel.getSiteInfo() + res.locals.home_heading = siteInfo.description || '' // Get collections with extras const collections = await DmsModel.getCollections({ all_fields: true,