UNPKG

dev-credit

Version:

Add essential developer credits (4 meta tags) to Next.js projects - Published by Softq Web Solutions

98 lines (87 loc) 3.15 kB
/** * dev-credit - Automatically add developer credits to Next.js metadata * @author Himangshu Mishra <contact@mishra.codes> * @website https://mishra.codes * @publisher Softq Web Solutions - softq.live */ const DEFAULT_CREDIT = { developer: "Himangshu Mishra", website: "https://mishra.codes", email: "contact@mishra.codes" }; /** * Merges developer credit metadata into Next.js metadata object * Adds essential meta tags (4 only) that will appear in the HTML head section * @param {Object} creditData - Developer credit information * @param {string} creditData.developer - Developer name * @param {string} creditData.website - Developer website * @param {string} creditData.email - Developer email * @param {Object} existingMetadata - Existing Next.js metadata object * @returns {Object} Merged metadata object with developer credits in head tags */ export function withDevMeta(creditData = {}, existingMetadata = {}) { const credit = { ...DEFAULT_CREDIT, ...creditData }; // Add essential meta tags only (4 tags to avoid spam) const otherMetadata = { other: { ...(existingMetadata.other || {}), 'developer': credit.developer, 'developer-website': credit.website, 'built-by': credit.developer, 'publisher': 'Softq Web Solutions' } }; // Add minimal author metadata const authorMetadata = { authors: [ ...(existingMetadata.authors || []), { name: credit.developer, url: credit.website } ], creator: credit.developer, publisher: 'Softq Web Solutions' }; return { ...existingMetadata, ...authorMetadata, ...otherMetadata }; } /** * Generates metadata for Next.js using default developer credit (Himangshu Mishra) * @param {Object} existingMetadata - Existing Next.js metadata object * @returns {Object} Merged metadata object with default developer credits */ export function getDevMeta(existingMetadata = {}) { return withDevMeta(DEFAULT_CREDIT, existingMetadata); } /** * Creates a custom meta tag specifically for developer attribution * @param {Object} creditData - Developer credit information * @returns {Object} Metadata object with essential developer attribution meta tags */ export function createDevMeta(creditData = {}) { const credit = { ...DEFAULT_CREDIT, ...creditData }; return { other: { 'developer': credit.developer, 'developer-website': credit.website, 'built-by': credit.developer, 'publisher': 'Softq Web Solutions' } }; } /** * Export default as withDevMeta for easier imports */ export default withDevMeta; /** * Named export of the default credit information */ export { DEFAULT_CREDIT }; // Backward compatibility exports export const withDevCredit = withDevMeta; export const getDevCreditMetadata = getDevMeta; export const createDevCreditMeta = createDevMeta;