domain-tote
v1.0.0
Published
A domain-level data container for site metadata, Open Graph information, and branding constants
Maintainers
Readme
domain-tote
Canonical URL:
https://alexstevovich.com/a/domain-tote-nodejs
Software URL:
https://midnightcitylights.com/software/domain-tote-nodejs
A simple data container for website-level metadata — including title, theme colors, Open Graph images, and social handles.domain-tote makes it easy to load and reuse domain configuration in servers, build tools, and template systems.
Installation
npm install domain-toteExample
import DomainTote from 'domain-tote';
// Initialize
const domain = new DomainTote();
// Load from JSON file
await domain.loadFromFile('./data/domain.json');
console.log(domain.siteName);
console.log(domain.twitterHandle);Example json
{
"siteName": "Example Studio",
"twitterHandle": "@examplestudio",
"themeColor": "#1e1e1e",
"ogImageUrl": "/ogimage.png",
"ogImageWidth": 1200,
"ogImageHeight": 630
}Methods
loadFromFile(filePath)
Asynchronously reads and loads a domain configuration JSON file into the instance.
Throws an error if the file doesn’t contain a valid object.
loadFromFileSync(filePath)
Synchronously loads domain data from disk.
reloadFromFile(filePath)
Clears all current values and reloads from disk asynchronously.
License
Licensed under the Apache License 2.0.
