{"id":22485548,"url":"https://github.com/ax2inc/multisite-module","last_synced_at":"2025-08-02T18:32:52.160Z","repository":{"id":57305376,"uuid":"147863899","full_name":"ax2inc/multisite-module","owner":"ax2inc","description":"Multisite features for your Nuxt project","archived":true,"fork":false,"pushed_at":"2018-10-18T15:46:35.000Z","size":93,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-02-27T07:00:24.959Z","etag":null,"topics":["module","multisite","nuxt"],"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/ax2inc.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}},"created_at":"2018-09-07T19:03:45.000Z","updated_at":"2023-04-05T01:35:16.000Z","dependencies_parsed_at":"2022-09-26T21:01:03.491Z","dependency_job_id":null,"html_url":"https://github.com/ax2inc/multisite-module","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax2inc%2Fmultisite-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax2inc%2Fmultisite-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax2inc%2Fmultisite-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ax2inc%2Fmultisite-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ax2inc","download_url":"https://codeload.github.com/ax2inc/multisite-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228499980,"owners_count":17929990,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["module","multisite","nuxt"],"created_at":"2024-12-06T17:12:49.425Z","updated_at":"2024-12-06T17:14:40.517Z","avatar_url":"https://github.com/ax2inc.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003e The project has moved to [https://github.com/ax2inc/nuxt-modules/tree/master/packages/multisite](https://github.com/ax2inc/nuxt-modules/tree/master/packages/multisite)\n\n# multisite-module\n[![npm (scoped with tag)](https://img.shields.io/npm/v/@ax2/multisite-module/latest.svg?style=flat-square)](https://npmjs.com/package/@ax2/multisite-module)\n[![npm](https://img.shields.io/npm/dt/@ax2/multisite-module.svg?style=flat-square)](https://npmjs.com/package/@ax2/multisite-module)\n[![CircleCI](https://img.shields.io/circleci/project/github/ax2inc/multisite-module.svg?style=flat-square)](https://circleci.com/gh/ax2inc/multisite-module)\n[![Codecov](https://img.shields.io/codecov/c/github/ax2inc/multisite-module.svg?style=flat-square)](https://codecov.io/gh/ax2inc/multisite-module)\n[![Dependencies](https://david-dm.org/ax2inc/multisite-module/status.svg?style=flat-square)](https://david-dm.org/ax2inc/multisite-module)\n[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n\n\n\u003e Multisite features for your Nuxt project\n\n[📖 **Release Notes**](./CHANGELOG.md)\n\n## Features\n\nThis module helps you bring multisite features to your Nuxt project. Here are the main features:\n\n- Current site detection based on host (or query string in development)\n- Contextual CSS vars declaration for site-specific theming\n- Contextual meta data\n\n## Setup\n\n- Install the module with your favorite package manager.\n\n```sh\nyarn add @ax2/multisite-module\n# Or npm i @ax2/multisite-module\n```\n\n- Add `@ax2/multisite-module` to `modules` section of `nuxt.config.js`.\n\n```js\n// nuxt.config.js\n\n{\n  modules: [\n    '@ax2/multisite-module',\n ],\n}\n```\n\n- Configure the module as needed by adding a `multisite` key to `nuxt.config.js`.\n\n```js\n// nuxt.config.js\n\n{\n  multisite: {\n  \t// Module options\n  }\n}\n```\n\n\n## Options\n\n### debug\n\n- Type: `Boolean`\n- **Default**: `false`\n\nSet this to `true` to force the module to get the current site from the query string.\n\n### sites\n\n- Type: `Array`\n\nList of sites.\n\n```js\n{\n  multisite: {\n    sites: [\n      {\n        id: 'my-site',\n        title: 'My awesome site',\n        isDefault: true,\n        hostPatterns: 'myawesomesite\\.com,myincrediblesite\\.(com|org)',\n        cssVars: {\n          '--primary-color': '#41B883',\n          '--secondary-color': '#3B8070',\n        },\n        head: {\n          link: [\n            { rel: 'icon', type: 'image/x-icon', href: '/my-site/favicon.ico' },\n          ],\n        },\n      },\n    ],\n  },\n}\n```\n\nEach item in `sites` can have a few options of its own:\n\n#### id\n\n- Type: `Integer|String`\n\nThe site's unique identifier.\n\n#### isDefault\n\n- Type: `Boolean`\n\nWether this site should be considered as the default one. Any request that cannot be resolved to one of the sites will fallback to the default one.\n\n#### hostPatterns\n\n- Type: `String`\n\nA list of comma-separated patterns to test against requests host in order to enable this site in production.\n\n#### cssVars\n\n- Type: `Object`\n\nCSS vars that should be set when visiting this site.\n\n#### head\n\n- Type: `Object`\n\nThis is the same as Nuxt's [head property](https://nuxtjs.org/api/configuration-head#the-head-property), options defined here are merged with the main `head` property definition.\n\n\u003e NOTE: Functions are not supported here\n\n## Usage\n\n### Development\n\nIn development, switch from one site to another by adding a `site` query parameter to the URL. The value should be the site's ID as defined in the module's configuration. ie: [http://127.0.0.1:8080/?site=my-site](http://127.0.0.1:8080/?site=my-site)\n\nActive site is stored in a cookie, so next time you visit [http://127.0.0.1:8080](http://127.0.0.1:8080), active site will be last used one.\n\n### Production\n\nIn production, active site is detected by matching request host against the patterns you defined in `hostPatterns` options. ie if you visit [http://myawesomesite.com](http://myawesomesite.com), `my-site` will be set as active site.\n\nA `$multisite` property is added to the app's context, it contains a few helpers that you can use in any component.\n\n### Properties\n\n#### site\n\n- Type: `Object`\n\nThe `site` property contains current site's configuration. You could use it to display the current site's title:\n\n```vue\n\u003ctemplate\u003e\n  \u003ch1 class=\"site-title\"\u003e\n    {{ $multisite.site.title }}\n  \u003c/h1\u003e\n\u003c/template\u003e\n```\n\n### Methods\n\n#### asset\n\n- Arguments\n  - `{String} path`: required\n  - `{Integer|String} site`: optional, defaults to current site ID\n- Return: `String`\n\nGet an asset's path for given site. If no site is specified, defaults to active site.\n\n```vue\n\u003ctemplate\u003e\n  \u003cheader\u003e\n    \u003cimg class=\"logo\" :src=\"$multisite.asset('logo.png')\"\u003e\n    \u003c!-- Renders to \u003cimg class=\"logo\" src=\"/my-site/logo.png\"\u003e --\u003e\n  \u003c/header\u003e\n\u003c/template\u003e\n```\n\n\u003e NOTE: It's recommended that you place site-specific assets in a directory named after the site's ID as defined in the module's options. Sites assets directories should be in the static/ directory.\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright (c) Ax2 Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fax2inc%2Fmultisite-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fax2inc%2Fmultisite-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fax2inc%2Fmultisite-module/lists"}