@ndla/licenses
A simple library for retrieving license information by abbreviation (and locale).
Installation
yarn add @ndla/licenses
npm install @ndla/licenses
Usage
Get license by abbreviation
import { licenses, getLicenseByAbbreviation } from "@ndla/licenses";
const license = getLicenseByAbbreviation(licenses.CC_BY_NC_4, "en");
console.log(license);
const license = getLicenseByAbbreviation(licenses.CC_BY_NC_4, "unknown-locale");
console.log(license);
const license = getLicenseByAbbreviation("unknown-license", "en");
console.log(license);
Get license right info by abbreviation/constant
import { getLicenseRightByAbbreviation, rights } from "@ndla/licenses";
const licenseRight = getLicenseRightByAbbreviation(rights.BY, "en");
console.log(licenseRight);
const licenseRight = getLicenseRightByAbbreviation(rights.CC, "unknown-locale");
console.log(licenseRight);
const licenseRight = getLicenseRightByAbbreviation("unknown-lr", "en");
console.log(licenseRight);
License right constants
import { rights } from "@ndla/licenses";
import Icon from "./Icons";
const LicenseIcon = ({ licenseRight }) => {
switch (licenseRight) {
case rights.BY:
return <Icon.LicenseBy />;
case rights.SA:
return <Icon.LicenseSa />;
default:
return undefined;
}
};
Available constants in rights object:
BY | 'by' | Attribution |
SA | 'sa' | Share-alike |
NC | 'nc' | Non-commercial |
ND | 'nd' | No derivative work |
PD | 'pd' | Public Domain |
CC0 | 'cc0' | Public Domain Dedication |
CC | 'cc' | Creative Commons |
COPYRIGHTED | 'copyrighted' | Copyrighted |
NA | 'n/a' | Not Appliccable |