{"id":28802965,"url":"https://github.com/nuxt-contrib/motd-json","last_synced_at":"2026-04-30T06:32:51.978Z","repository":{"id":66052216,"uuid":"224483339","full_name":"nuxt-contrib/motd-json","owner":"nuxt-contrib","description":"Library for retrieving a random motd from a json input with filter support","archived":false,"fork":false,"pushed_at":"2023-12-15T11:46:55.000Z","size":379,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-30T06:32:39.851Z","etag":null,"topics":["json","motd"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuxt-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-27T17:28:01.000Z","updated_at":"2020-09-07T14:11:53.000Z","dependencies_parsed_at":"2023-12-15T12:50:48.317Z","dependency_job_id":null,"html_url":"https://github.com/nuxt-contrib/motd-json","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nuxt-contrib/motd-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-contrib%2Fmotd-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-contrib%2Fmotd-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-contrib%2Fmotd-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-contrib%2Fmotd-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxt-contrib","download_url":"https://codeload.github.com/nuxt-contrib/motd-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-contrib%2Fmotd-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32457110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","motd"],"created_at":"2025-06-18T08:30:47.421Z","updated_at":"2026-04-30T06:32:51.971Z","avatar_url":"https://github.com/nuxt-contrib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# motd-json\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Circle CI][circle-ci-src]][circle-ci-href]\n[![Codecov][codecov-src]][codecov-href]\n\nLibrary for retrieving a random motd from a json input with filter support\n\n# Features\n\n- validation of json against a JSON Schema\n- filter motd's by region\n- filter motd's by period / holidays\n- filter motd's by custom tags\n\n# Messages definition\n```js\n[\n  {\n    \"message\": \u003cstring\u003e, // required, the message of the day\n    \"regions\": [\u003cstring\u003e], // optional, the regions/territories to show this message for\n    \"periods\": [{ // optional, use 0000 as year for a yearly recurring period\n      \"from\": \u003cdate-time\u003e, // the start date-time this message could be shown\n      \"till\": \u003cdate-time\u003e // the end date-time this message could be shown\n    }],\n    \"tags\": { // optional\n      {\n        \"name\": \u003cstring\u003e,\n        \"type\": [\"semver\", \"number\", \"boolean\", \"set\"],\n        \"value\":\n          \u003cstring\u003e // for semver\n          \u003cnumber\u003e // for number, matches only equal or greater than\n          \u003cboolean\u003e // for boolean\n          Array\u003cany\u003e // for set\n    }\n  }\n]\n```\n\nFor easy validation a JSON Schema and validate export is included:\n\n\u003e The peer dependency ajv needs to be installed for validate to work\n\n```js\nimport { validate } from 'motd-json'\nimport yourMessages from './your-messages.json'\n\nawait validate(yourMessages) // resolves to true or false\n```\n\n# Options\n\n\u003e These are the options you could pass to the `motd` export for retrieving a message\n\n- `region` _string_\n- `regional` _boolean_\n\nIf _region_ is empty and _regional_ is true, the users region is determined from the territory string of their os locale using [`os-locale`](https://github.com/sindresorhus/os-locale)\n\nMessages are matched when they either dont list any region or the user region is included in the list of regions for a message\n\n- `date` _string_\n\nIf not empty then only messages are matched that either dont have a period listed or where the provided date falls within the configured period for the message\n\n- `tags` _object_\n\nA key/value mapping of tag values for the current user. If a message contains a list of tags, then the name of those tags is used as key to lookup the value.\nThe mapped value is then compared to the message tag values to determine whether the message should be included or not\n\n# Usage\n\n### Basic with validation\n\n```js\nimport { motd, validate } from 'motd-json'\nimport messages from './my-messages.json'\n\nif (validate(messages)) {\n  const options = {\n    regional: true,\n    tags: {\n      typescript: false,\n      version: 'v2.2.3',\n      modules: ['axios', 'i18n']\n    }\n  }\n\n  console.log(motd(messages, options))\n}\n```\n\n### Create a motd generator\n\n```js\nimport { filter, motd } from 'motd-json'\nimport messages from './my-messages.json'\n\nconst options = {\n  regional: true,\n  tags: {\n    typescript: false,\n    version: 'v2.2.3',\n    modules: ['axios', 'i18n']\n  }\n}\n\nconst filteredMessages = filter(messages, options)\nconst motdGenerator = () =\u003e motd(filteredMessages)\n\nmotdGenerator()\nmotdGenerator()\n```\n\n\n# Example messages\n\n```js\n// messages.json\n[\n  {\n    message: 'some message'\n  },\n  {\n    message: 'my multi-region message',\n    regions: ['en', 'nl']\n  },\n  {\n    message: 'mijn test bericht',\n    regions: ['nl']\n  },\n  {\n    message: 'Happy New Year',\n    periods: [{\n      from: '0000-12-28',\n      till: '0000-12-31'\n    }, {\n      from: '0000-01-01',\n      till: '0000-01-05'\n    }]\n  },\n  {\n    message: 'Merry Christmas',\n    period: {\n      from: '0000-12-01',\n      till: '0000-12-27'\n    }\n  },\n  {\n    message: 'Fijne Sinterklaas',\n    regions: ['nl'],\n    period: {\n      from: '2019-11-16',\n      till: '2019-12-05'\n    }\n  },\n  {\n    message: 'You are using v2.x',\n    tags: [\n      {\n        name: 'version',\n        type: 'semver',\n        value: 'v2.x'\n      }\n    ]\n  },\n  {\n    message: 'You are using v3.x',\n    tags: [\n      {\n        name: 'version',\n        type: 'semver',\n        value: 'v3.x'\n      }\n    ]\n  },\n  {\n    message: 'You are using 10 modules or more',\n    tags: [\n      {\n        name: 'modulesCount',\n        type: 'number',\n        value: 10\n      }\n    ]\n  },\n  {\n    message: 'You are using the axios or http module',\n    tags: [\n      {\n        name: 'modules',\n        type: 'set',\n        value: ['axios', 'http']\n      },\n    ]\n  },\n  {\n    message: 'You are using typescript',\n    tags: [\n      {\n        name: 'typescript',\n        type: 'boolean',\n        value: true\n      }\n    ]\n  }\n]\n```\n# TODO\n\n- [ ] Add support for different comparison operators for tags\n\n# License\n\nMIT\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/motd-json/latest.svg?style=flat-square\n[npm-version-href]: https://npmjs.com/package/motd-json\n\n[npm-downloads-src]: https://img.shields.io/npm/dt/motd-json.svg?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/motd-json\n\n[circle-ci-src]: https://img.shields.io/circleci/project/github/jsless/motd-json.svg?style=flat-square\n[circle-ci-href]: https://circleci.com/gh/jsless/motd-json\n\n[codecov-src]: https://img.shields.io/codecov/c/github/jsless/motd-json.svg?style=flat-square\n[codecov-href]: https://codecov.io/gh/jsless/motd-json\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-contrib%2Fmotd-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxt-contrib%2Fmotd-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-contrib%2Fmotd-json/lists"}