Skip to content

Commit

Permalink
feat: Multi Domain Support
Browse files Browse the repository at this point in the history
  • Loading branch information
gja committed May 6, 2019
1 parent b738398 commit a4679d2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 42 deletions.
4 changes: 2 additions & 2 deletions app/server/data-loaders/home-page-data.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-unused-vars */
import { Collection } from "@quintype/framework/server/api-client";

export async function loadHomePageData(client, config) {
const collection = await Collection.getCollectionBySlug(client, "home", { "item-type": "collection" }, { depth: 1 });
export async function loadHomePageData(client, config, slug) {
const collection = await Collection.getCollectionBySlug(client, slug, { "item-type": "collection" }, { depth: 1 });

This comment has been minimized.

Copy link
@asimqt

asimqt May 7, 2019

Contributor

Should we fallback to home?

return {
collection: collection.asJson(),
cacheKeys: collection.cacheKeys(config["publisher-id"])
Expand Down
4 changes: 2 additions & 2 deletions app/server/load-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export function loadErrorData(error, config) {
});
}

export function loadData(pageType, params, config, client, { host, next }) {
export function loadData(pageType, params, config, client, { host, next, domainSlug }) {
function _loadData() {
switch (pageType) {
case PAGE_TYPE.HOME_PAGE:
return loadHomePageData(client, config);
return loadHomePageData(client, config, params.collectionSlug);
case PAGE_TYPE.HOME_PREVIEW:
return loadHomePageData(client, config);
case PAGE_TYPE.SECTION_PAGE:
Expand Down
13 changes: 4 additions & 9 deletions app/server/routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
generateStoryPageRoutes,
generateSectionPageRoutes
} from "@quintype/framework/server/generate-routes";
import { generateCommonRoutes } from "@quintype/framework/server/generate-routes";
import { PAGE_TYPE, TAG_PAGE_URL_PREFIX } from "../isomorphic/constants";

// Static Routes are not part of the PWA. Also, they aren't part of the JS bundle
Expand All @@ -28,7 +25,6 @@ export const STATIC_ROUTES = [
];

const ISOMORPHIC_ROUTES = [
{ path: "/", pageType: PAGE_TYPE.HOME_PAGE, exact: true },
{
path: "/template-options",
pageType: PAGE_TYPE.CATALOG_PAGE,
Expand All @@ -49,9 +45,8 @@ const ISOMORPHIC_ROUTES = [
{ path: "/search", pageType: PAGE_TYPE.SEARCH_PAGE, exact: true }
];

export function generateRoutes(config) {
return ISOMORPHIC_ROUTES.concat(
generateSectionPageRoutes(config, { addSectionPrefix: true }),
generateStoryPageRoutes(config)
export function generateRoutes(config, domainSlug) {
return config.memoize(`routes${domainSlug}`, () =>
ISOMORPHIC_ROUTES.concat(generateCommonRoutes(config, domainSlug))
);
}
2 changes: 2 additions & 0 deletions config/publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ host_to_api_host:
host_to_automatic_api_host:
- "-web"
- ".malibu"
domain_mapping:
subdomain.lvh.me: subdomain
65 changes: 37 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "MIT",
"dependencies": {
"@quintype/components": "^2.0.1",
"@quintype/framework": "^3.0.2",
"@quintype/framework": "^3.3.1",
"@quintype/seo": "^1.24.0",
"fontfaceobserver": "^2.1.0",
"lodash": "^4.17.11",
Expand Down

0 comments on commit a4679d2

Please sign in to comment.