Skip to content

Commit

Permalink
Add querySelectors and templateSelectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
espen42 committed Sep 5, 2021
1 parent f62dea1 commit cfa464f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion next/src/components/templateSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ import { appKey } from '../enonic-connection-config';

import FolderPage from "./templates/Folder";

import ListPage from "./templates/List";
import MoviePage from "./templates/Movie";
import PersonPage from "./templates/Person";

// Content types mapped to full guillotine query strings.
// If type is not found here, falls back to the default template in templates/item.tsx
const contentTypeSpecificTemplate = {
'base:folder': FolderPage
//'base:folder': FolderPage

'base:folder': ListPage,
[`${appKey}:person`]: PersonPage,
[`${appKey}:movie`]: MoviePage
};

export const getTemplate = (contentType) => contentTypeSpecificTemplate[contentType] || DefaultPage;
6 changes: 6 additions & 0 deletions next/src/shared/data/querySelector.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { getContentDataQuery } from "./queries/_defaultGetData";
import { appKey } from '../../enonic-connection-config';

import LIST_QUERY from './queries/getList';
import MOVIE_QUERY from './queries/getMovie';
import PERSON_QUERY from './queries/getPerson';

// Content types mapped to full guillotine query strings.
// If type is not found here, a LOW-PERFORMING default query is selected from getContentDataQuery.
const contentTypeSpecificQueries = {
'base:folder': LIST_QUERY,
[`${appKey}:movie`]: MOVIE_QUERY,
[`${appKey}:person`]: PERSON_QUERY,
// 'my.example.app:content-type': '{ guillotine { get { custom query string etc } } }'
};

Expand Down

0 comments on commit cfa464f

Please sign in to comment.