@kth/cortina-block
This package exposes an express middleware, that fetches som predefined blocks from Cortina CMS.
The blocks are then stored in res.locals.blocks
, for use in Handlebars or similar.
Blocks can optionaly be cached in Redis.
Installation
npm install @kth/cortina-block
Usage
import { cortinaMiddleware } from '@kth/cortina-block'
apply middleware
server.use(
'',
cortinaMiddleware({
blockApiUrl,
blocksConfig,
redisConfig,
})
)
Default blocks that will be fetched can be found in config.ts. If you want to fetch other blocks or override the id of the default blocks, provide the optional blocksConfig
.
Options
Changes after style 10
Blocks title, image and secondaryMenu are no longer used by the apps.
That also means that a bunch of config is no longer needed.
Upgrade from @kth/cortina-block 6
- Config headers is no longer used.
- Config localeText is no longer used.
- Config resourceUrl is no longer used.
- Config siteName is no longer used.
- Config useStyle10 is no longer used.
Upgrade from wrapper in @kth/kth-node-web-common
- Config addBlocks has been renamed to blocksConfig.
- Config blockUrl has been renamed to blockApiUrl.
- Config blockVersion is no longer used.
- Config globalLink is no longer used.
- Config hostUrl is no longer used.
- Config proxyPrefixPath is no longer used.
- Config useStyle10 is no longer used.
Returned blocks
All fetched blocks will be avalible on res.locals.blocks
.
{
megaMenu: "\n\n\n\n <nav class=\"b…\n </nav>\n\n \n\n",
footer: "\n\n\n <div class=\"blo… </div>\n </div>\n\n\n",
search: "\n\n\n <div class=\"blo…aded=!0);</script>\n\n\n",
etc..
}