1.0.0 • Published 2 years ago

nguniversal-express-engine-meta-tags-replacer v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

nguniversal-express-engine-meta-tags-replacer

language license npm version npm download

Description

This package provides a function for handling the page request in Angular SSR app, which needs its specific meta tag content attribute value. This can be mostly used for Facebook sharing.

Installation

npm i nguniversal-express-engine-meta-tags-replacer

Usage example:

import { metaTagsReplacerRequestHandler, IMetaTag } from 'nguniversal-express-engine-meta-tags-replacer'
import { APP_BASE_HREF } from '@angular/common'

server.get(['/some-path'], (req, res) => {
  metaTagsReplacerRequestHandler(
    indexHtml,
    {
      req,
      providers: [
        { provide: APP_BASE_HREF, useValue: req.baseUrl }
      ]
    },
    res,
    [
      {
        propertyValue: 'og:image',
        contentValue: '/page/specific/image'
      },
      {
        propertyValue: 'og:title',
        contentValue: 'Page specific title'
      }
    ] as IMetaTag[]
  )
})