@pyyupsk/copyright
v0.0.1
Published
A framework-agnostic TypeScript library for displaying copyright notices with auto year calculation, preset formats, custom templates, and React support
Maintainers
Readme
@pyyupsk/copyright
A framework-agnostic TypeScript library for displaying copyright notices with auto year calculation, preset formats, custom templates, and React support.
Features
- Auto year calculation with year ranges
- 4 preset formats (minimal, standard, full, legal)
- Custom template support with variable substitution
- HTML output with styling (className, style, tag)
- React component with declarative props API
- Direct DOM rendering via selector or Element reference
- Zero runtime dependencies for core library
- Dual ESM/CJS output
- Full TypeScript support
Installation
npm install @pyyupsk/copyright
# or
bun add @pyyupsk/copyrightQuick Start
Basic Usage
import { Copyright } from "@pyyupsk/copyright";
const copyright = new Copyright({ owner: "ACME Corp" });
console.log(copyright.getText()); // © 2026 ACME CorpYear Range
const copyright = new Copyright({
owner: "ACME Corp",
startYear: 2020,
});
console.log(copyright.getText()); // © 2020-2026 ACME CorpPreset Formats
const copyright = new Copyright({
owner: "ACME Corp",
format: "standard",
});
console.log(copyright.getText()); // Copyright © 2026 ACME Corp
// Available formats: minimal, standard, full, legalCustom Template
const copyright = new Copyright({
owner: "ACME Corp",
template: "Made by {owner} in {year}",
});
console.log(copyright.getText()); // Made by ACME Corp in 2026
// Available variables: {symbol}, {year}, {owner}, {startYear}, {endYear}HTML Output
const copyright = new Copyright({ owner: "ACME Corp" });
// Default span
console.log(copyright.toHTML());
// <span>© 2026 ACME Corp</span>
// With options
console.log(
copyright.toHTML({
tag: "footer",
className: "copyright-text",
style: { color: "gray" },
}),
);
// <footer class="copyright-text" style="color: gray">© 2026 ACME Corp</footer>DOM Rendering
const copyright = new Copyright({ owner: "ACME Corp" });
// Render to selector
copyright.render("#footer");
// Render to Element
const container = document.getElementById("footer");
copyright.render(container, { tag: "small", className: "text-muted" });React Component
import { Copyright } from "@pyyupsk/copyright/react";
function Footer() {
return (
<Copyright
owner="ACME Corp"
startYear={2020}
format="standard"
as="footer"
className="text-gray-500"
/>
);
}API Reference
Copyright Class
Constructor
new Copyright(options: CopyrightOptions);Options
| Option | Type | Default | Description |
| ----------- | ---------------------------------------------- | ----------- | --------------------------- |
| owner | string | (required) | Copyright owner name |
| startYear | number | current | Start year for range |
| endYear | number \| "auto" | "auto" | End year (auto = current) |
| format | "minimal" \| "standard" \| "full" \| "legal" | "minimal" | Preset format |
| template | string | - | Custom template (overrides) |
Methods
getText()- Returns plain text copyright stringtoHTML(options?)- Returns HTML string with optional tag, className, stylerender(target, options?)- Renders to DOM element (selector or Element)setOptions(options)- Updates options (chainable)static create(options)- Factory method
React <Copyright /> Component
All CopyrightOptions plus:
| Prop | Type | Default | Description |
| ----------- | -------- | -------- | -------------- |
| as | string | "span" | Element type |
| tag | string | "span" | Alias for as |
| className | string | - | CSS class |
| style | object | - | Inline styles |
