New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kth/cortina-block

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kth/cortina-block

Node.js module for fetching Cortina blocks and optionally cache using Redis.

  • 6.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
918
increased by65.7%
Maintainers
0
Weekly downloads
 
Created
Source

@kth/cortina-block

This package exports:

  • cortinaMiddleware - Express middleware to fectch cortina blocks and store them in res.locals.blocks (optional resis cache)
  • cortina - function that fetches cortina blocks (optional redis cache). Used by cortinaMiddleware.
  • prepare - function for formatting fetched cortina blocks, e.g. site name and locale link text. Used by cortinaMiddleware

Installation

npm install @kth/cortina-block

Usage

import { cortinaMiddleware } from '@kth/cortina-block'

apply middleware

server.use(
  '',
  cortinaMiddleware({
    blockApiUrl,
    siteName,
    localeText,
    resourceUrl,
    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:

const blocksConfig = {
  anotherBlock: 'id',
}

Options

  • blockApiUrl is required. Should point to the Cortina block API endpoint.

  • headers is optional, pass headers used when fetching Cortina blocks.

  • blocks is optional. It's a plain object containing Cortina block IDs. The following IDs are default and can be overridden.

    • title defaults to 1.260060.
    • megaMenu defaults to 1.855134.
    • secondaryMenu defaults to 1.865038.
    • image defaults to 1.77257.
    • footer defaults to 1.202278.
    • search defaults to 1.77262.
    • language optional object with language block IDs.
      • en defaults to 1.77273.
      • sv defaults to 1.272446.
    • klaroConfig defaults to 1.1137647.
    • matomoAnalytics defaults to 1.714097.
  • redisConfig is optional. An object parsed from kth-node-configuration, containing host and port. If provided, blocks will be cached in redis.

Returned blocks


title: "\n\n\n  <h1 class=\"bloc…logy</a>\n  </h1>\n\n\n",
megaMenu: "\n\n\n\n  <nav class=\"b…\n     </nav>\n\n  \n\n",
secondaryMenu: "\n\n\n  <div class=\"blo…   </ul>\n  </div>\n\n\n",
image: "\n\n\n  <figure class=\"…    \n  </figure>\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",
language: "\n\n\n  <a class=\"block…KTH på svenska</a>\n\n\n",
analytics: "\n\n\n  \n    <!-- conte…r\n};</script>\n  \n\n\n",
gtmAnalytics: "\n\n\n  <!-- Begin JavaS…entId-1_714097 -->\n\n\n",
gtmNoscript: "\n\n\n  <!-- Begin HTML …entId-1_714099 -->\n\n\n"

Keywords

FAQs

Package last updated on 10 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc