-
Notifications
You must be signed in to change notification settings - Fork 0
basic usage
github-actions[bot] edited this page May 31, 2026
·
2 revisions
import { cycleMonth, cdnUrl } from 'moon-cycle';
const filename = cycleMonth(new Date());
const url = cdnUrl(filename, 'mm', 256, 75);
console.log(url);
// 'https://cdn.jsdelivr.net/gh/acamarata/moon-cycle@main/mm-256-75/354.webp'import { cycleMonth, cdnUrl } from 'moon-cycle';
// March 23, 2023 — 1 Ramadan 1444 AH
const date = new Date(2023, 2, 23);
const filename = cycleMonth(date);
const url = cdnUrl(filename, 'mm', 256, 75);
console.log(filename); // e.g. '001.webp'
console.log(url);import { cycleMonth, cdnUrl } from 'moon-cycle';
const filename = cycleMonth(new Date());
// Available sizes: 256 or 512 pixels
// Available quality: 75 or 85
const urlMedium = cdnUrl(filename, 'mm', 256, 75);
const urlLarge = cdnUrl(filename, 'mm', 512, 85);
console.log(urlMedium);
console.log(urlLarge);import { cycleYear, cdnUrl } from 'moon-cycle';
// cycleYear maps to 2023 hourly NASA photographs
const filename = cycleYear(new Date());
const url = cdnUrl(filename, 'my', 256, 75);
console.log(url);If you have cloned the repo and copied the image folder to your static assets:
import { cycleMonth, imageFolder } from 'moon-cycle';
const folder = imageFolder('mm', 256, 75); // 'mm-256-75'
const filename = cycleMonth(new Date());
const src = `/moon/${folder}/${filename}`;
// Use src in an <img> tagimport { cycleMonth, cdnUrl } from 'moon-cycle';
function MoonPhase({ date }: { date: Date }) {
const filename = cycleMonth(date);
const src = cdnUrl(filename, 'mm', 256, 75);
return (
<img
src={src}
alt="Moon phase"
width={256}
height={256}
/>
);
}const { cycleMonth, cdnUrl } = require('moon-cycle');
const filename = cycleMonth(new Date());
const url = cdnUrl(filename, 'mm', 256, 75);
console.log(url);moon-cycle · MIT License · GitHub · Issues
Guides
Examples
API
Reference
Community