Skip to content

Commit

Permalink
#38: improve examples and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
espen42 committed Sep 9, 2021
1 parent f4e0532 commit 1ded6b4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/BasePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Custom500 from './errors/500';
import Custom404 from './errors/404';
import CustomError from './errors/Error';

import DefaultPage from "../components/pagetypes/Default";
import DefaultPage from "../components/pagetypes/_Default";
import { pageSelector} from "../selectors/pageSelector";

const selectPage = (contentType) => pageSelector[contentType] || DefaultPage;
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions src/selectors/pageSelector.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { appKey } from '../enonic-connection-config';

// Example:
// EXAMPLE:
// import MyPage from '../components/pagetypes/MyPage;

// Content types mapped to top-level react components that render that content type.
// XP content types ('type' from the second data response in fetchContent.ts) mapped to top-level react components that render that content type.
// If content type is not found here, falls back to the default page renderer in pages/Default.tsx
export const pageSelector = {

// Examples:
//'my-hardcoded-appname:my-content-type': MyPage,
//[`${appKey}:my-content-type`]: MyPage,
// EXAMPLES:
// 'my-hardcoded-appname:my-content-type': MyPage,
// [`${appKey}:my-content-type`]: MyPage,
// 'base:folder': MyFolderPage
// ...etc
};

17 changes: 11 additions & 6 deletions src/selectors/querySelector.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { appKey } from '../enonic-connection-config';

// Example:
// EXAMPLE:
// import MY_IMPORTED_QUERY from '../shared/data/queries/getMyContentType';

// Content types mapped to full guillotine query strings.
// XP content types ('type' from the first meta response in fetchContent.ts) mapped to full guillotine query strings.
// If type is not found here, a LOW-PERFORMING default query is selected from _getDefaultData.ts!
export const querySelector = {

// Examples:
// EXAMPLES:
// 'my.harcoded.appname:my-content-type': '{ guillotine { get { hardcoded custom query string etc } } }'
// [`${appKey}:my-content-type`]: MY_IMPORTED_QUERY,
// 'base:folder`: MY_FOLDER_QUERY
// ...etc
};



// Content types mapped to a getVariables function, that will return appropriate variables for the placeholders in the corresponding query: idOrPath => variablesObject
// XP content types ('type' from the first meta response in fetchContent.ts) mapped to a getVariables function,
// which will return appropriate variables for the placeholders in the corresponding query: idOrPath => variablesObject
// idOrPath (the _id or _path of a target content item) is usually used in queries, so that's the argument the function will be called with.
// Whenever the selected query only uses the idOrPath placeholder (including the default query), nothing needs to be added here since the default function is enough: idOrPath => ({idOrPath: idOrPath})
export const variablesGetterSelector = {

// EXAMPLE:
// 'my.example.app:data-type': (idOrPath) => ({ idOrPath: idOrPath, otherPlaceHolder: otherValue })
// EXAMPLES:
// 'my.harcoded.appname:content-type': (idOrPath) => ({ idOrPath: idOrPath, otherParameter: otherValue }), // If MY_IMPORTED_QUERY uses a $otherParameter parameter
//'base:folder': (idOrPath) => ({ idOrPath: idOrPath, maxChildren: 1000 }) // If MY_FOLDER_QUERY uses a $maxChildren parameter
// ...etc
};

0 comments on commit 1ded6b4

Please sign in to comment.