opscms-short-links-plugin
v1.2.0
Published
Share-button short links for a multi-tenant OpsCMS platform: a short-links collection, POST /api/share to mint a link to one of a site's own pages, and GET /api/go/:code to redirect with click counting.
Maintainers
Readme
opscms-short-links-plugin
Share-button short links for an OpsCMS platform. Built on opscms-sdk.
short-linkscollection — codes are unique across the platform; the target is validated http/https on write, so a redirect can never be ajavascript:ordata:link.POST /api/share— a storefront asks for a short link to one of a site's own pages. Public, throttled per address, and capped per site per hour; the target's origin must belong to a site that is serving, and that site must have installed this plugin. An existing link to the same page is reused.GET /api/go/:code— the redirect (302, never cached, so the click count means something). It counts and reports people only: a crawler or link preview is sent on (or, for a preview program and a link that has its own card, shown that card) without a click. The link's utm values are added to the target, the canonical address is named in aLinkheader, and a person following it raises the system eventshort_link.clickedfor the site's workflows.
Use
// payload.config.ts, after the platform has registered its services
import { shortLinksPlugin } from 'opscms-short-links-plugin'
export default buildConfig({ plugins: [shortLinksPlugin()] })The platform must call registerPlatform() from opscms-sdk before the plugin is applied. Without a platform the plugin
throws a clear message on first use.
The plugin's logo is icon.svg in this package; the platform reads it when the plugin is installed.
