-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(domains): support multiply domains (#14)
- Loading branch information
Showing
11 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SET_DOMAIN, SET_LOCALES } from '~typo3/store/mutation-types' | ||
import { getHostByURL } from '~typo3/lib/route' | ||
|
||
/** | ||
* Find domain based on host and available domain list | ||
* | ||
* @param {Object} context - Nuxt context | ||
* @returns {Object} domain - Active domain object | ||
*/ | ||
function getDomain({ app, req }) { | ||
// get host depends on environment - SSR or browser | ||
if (app.$typo3.options.domains && app.$typo3.options.domains.length) { | ||
const host = getHostByURL(req ? req.headers.host : window.location.origin) | ||
return app.$typo3.options.domains.find(domain => domain.name === host) | ||
} | ||
return false | ||
} | ||
|
||
/** | ||
* Set active domain to store | ||
* | ||
* @param {Object} Context - Nuxt context | ||
* @param {Object} domain - Active domain object | ||
* @returns {void} | ||
*/ | ||
function setDomain({ store, app }, domain) { | ||
if (domain) { | ||
app.$typo3.api.setOptions(domain.api) | ||
store.commit(SET_LOCALES, domain.i18n.locales) | ||
store.commit(SET_DOMAIN, domain) | ||
} | ||
} | ||
|
||
export { getDomain, setDomain } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { getDomain, setDomain } from '~typo3/lib/domains' | ||
export default (context, options) => { | ||
return { | ||
list: options.domains ? options.domains : [], | ||
getDomain: () => getDomain(context), | ||
setDomain: domain => setDomain(context, domain) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const SET_INITIAL = 'SET_INITIAL_DATA' | ||
export const SET_LOCALE = 'SET_LOCALE_ACTIVE' | ||
export const SET_LOCALES = 'SET_AVAILABLE_LOCALES' | ||
export const SET_PAGE = 'SET_PAGE_DATA' | ||
export const SET_DOMAIN = 'SET_DOMAIN' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters