create-sitecore-jss 20.0.0-canary.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MD +202 -0
- package/dist/InitializerFactory.js +49 -0
- package/dist/common/Initializer.js +2 -0
- package/dist/common/args/base.js +2 -0
- package/dist/common/args/styleguide.js +2 -0
- package/dist/common/prompts/base.js +40 -0
- package/dist/common/prompts/styleguide.js +28 -0
- package/dist/common/steps/index.js +13 -0
- package/dist/common/steps/install.js +46 -0
- package/dist/common/steps/next.js +60 -0
- package/dist/common/steps/transform.js +185 -0
- package/dist/common/utils/cmd.js +39 -0
- package/dist/common/utils/helpers.js +92 -0
- package/dist/index.js +91 -0
- package/dist/init-runner.js +50 -0
- package/dist/initializers/nextjs/args.js +2 -0
- package/dist/initializers/nextjs/index.js +65 -0
- package/dist/initializers/nextjs/prompts.js +19 -0
- package/dist/initializers/nextjs/remove-dev-dependencies.js +24 -0
- package/dist/initializers/nextjs-styleguide/index.js +49 -0
- package/dist/templates/nextjs/.env +49 -0
- package/dist/templates/nextjs/.eslintrc +25 -0
- package/dist/templates/nextjs/.gitattributes +11 -0
- package/dist/templates/nextjs/.gitignore +33 -0
- package/dist/templates/nextjs/.graphql-let.yml +10 -0
- package/dist/templates/nextjs/.prettierignore +1 -0
- package/dist/templates/nextjs/.prettierrc +8 -0
- package/dist/templates/nextjs/LICENSE.txt +202 -0
- package/dist/templates/nextjs/README.md +3 -0
- package/dist/templates/nextjs/next-env.d.ts +6 -0
- package/dist/templates/nextjs/next.config.js +56 -0
- package/dist/templates/nextjs/package.json +88 -0
- package/dist/templates/nextjs/public/favicon.ico +0 -0
- package/dist/templates/nextjs/public/sc_logo.svg +20 -0
- package/dist/templates/nextjs/scripts/bootstrap.ts +40 -0
- package/dist/templates/nextjs/scripts/fetch-graphql-introspection-data.ts +49 -0
- package/dist/templates/nextjs/scripts/generate-component-factory.ts +95 -0
- package/dist/templates/nextjs/scripts/generate-config.ts +85 -0
- package/dist/templates/nextjs/scripts/generate-plugins.ts +103 -0
- package/dist/templates/nextjs/scripts/scaffold-component.ts +89 -0
- package/dist/templates/nextjs/scripts/templates/component-factory.ts +119 -0
- package/dist/templates/nextjs/scripts/templates/component-src.ts +27 -0
- package/dist/templates/nextjs/scripts/utils.ts +59 -0
- package/dist/templates/nextjs/sitecore/config/{{appName}}.config +151 -0
- package/dist/templates/nextjs/src/Layout.tsx +53 -0
- package/dist/templates/nextjs/src/Navigation.tsx +27 -0
- package/dist/templates/nextjs/src/NotFound.tsx +19 -0
- package/dist/templates/nextjs/src/assets/app.css +28 -0
- package/dist/templates/nextjs/src/components/ContentBlock.tsx +24 -0
- package/dist/templates/nextjs/src/lib/component-props/index.ts +23 -0
- package/dist/templates/nextjs/src/lib/data-fetcher.ts +16 -0
- package/dist/templates/nextjs/src/lib/dictionary-service-factory.ts +30 -0
- package/dist/templates/nextjs/src/lib/layout-service-factory.ts +25 -0
- package/dist/templates/nextjs/src/lib/next-config/plugins/graphql.js +32 -0
- package/dist/templates/nextjs/src/lib/next-config/plugins/monorepo.js +27 -0
- package/dist/templates/nextjs/src/lib/page-props-factory/index.ts +50 -0
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/componentProps.ts +38 -0
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/normalMode.ts +75 -0
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/previewMode.ts +27 -0
- package/dist/templates/nextjs/src/lib/page-props.ts +16 -0
- package/dist/templates/nextjs/src/lib/sitemap-fetcher/index.ts +25 -0
- package/dist/templates/nextjs/src/lib/sitemap-fetcher/plugins/graphqlSitemapService.ts +36 -0
- package/dist/templates/nextjs/src/pages/404.tsx +5 -0
- package/dist/templates/nextjs/src/pages/[[...path]].tsx +91 -0
- package/dist/templates/nextjs/src/pages/_app.tsx +19 -0
- package/dist/templates/nextjs/src/pages/_error.tsx +35 -0
- package/dist/templates/nextjs/src/pages/api/editing/data/[key].ts +24 -0
- package/dist/templates/nextjs/src/pages/api/editing/render.ts +30 -0
- package/dist/templates/nextjs/src/temp/.gitignore +3 -0
- package/dist/templates/nextjs/src/temp/GraphQLIntrospectionResult.json +22216 -0
- package/dist/templates/nextjs/tsconfig.json +42 -0
- package/dist/templates/nextjs/tsconfig.scripts.json +6 -0
- package/dist/templates/nextjs-styleguide/data/component-content/.gitignore +0 -0
- package/dist/templates/nextjs-styleguide/data/component-content/Styleguide/ContentReuse/LoremIpsumContentBlock/en.yml +9 -0
- package/dist/templates/nextjs-styleguide/data/content/.gitignore +0 -0
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ContentListField/Item1/en.yml +6 -0
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ContentListField/Item2/en.yml +6 -0
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ItemLinkField/Item1/en.yml +6 -0
- package/dist/templates/nextjs-styleguide/data/content/Styleguide/ItemLinkField/Item2/en.yml +6 -0
- package/dist/templates/nextjs-styleguide/data/dictionary/en.yml +4 -0
- package/dist/templates/nextjs-styleguide/data/dictionary/{{language}}.yml +4 -0
- package/dist/templates/nextjs-styleguide/data/media/files/jss.pdf +0 -0
- package/dist/templates/nextjs-styleguide/data/media/img/jss_logo.png +0 -0
- package/dist/templates/nextjs-styleguide/data/media/img/sc_logo.png +0 -0
- package/dist/templates/nextjs-styleguide/data/routes/en.yml +63 -0
- package/dist/templates/nextjs-styleguide/data/routes/graphql/en.yml +27 -0
- package/dist/templates/nextjs-styleguide/data/routes/graphql/sample-1/en.yml +9 -0
- package/dist/templates/nextjs-styleguide/data/routes/graphql/sample-2/en.yml +9 -0
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/custom-route-type/en.yml +12 -0
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/en.yml +246 -0
- package/dist/templates/nextjs-styleguide/data/routes/styleguide/{{language}}.yml +25 -0
- package/dist/templates/nextjs-styleguide/data/routes/{{language}}.yml +4 -0
- package/dist/templates/nextjs-styleguide/package.json +13 -0
- package/dist/templates/nextjs-styleguide/scripts/disconnected-mode-proxy.ts +48 -0
- package/dist/templates/nextjs-styleguide/scripts/scaffold-component.ts +130 -0
- package/dist/templates/nextjs-styleguide/scripts/templates/component-manifest.ts +30 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/component-content.sitecore.ts +117 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/ContentBlock.sitecore.ts +19 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Checkbox.sitecore.ts +23 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-ContentList.sitecore.ts +32 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Custom.sitecore.ts +23 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Date.sitecore.ts +23 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-File.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Image.sitecore.ts +23 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-ItemLink.sitecore.ts +32 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Link.sitecore.ts +25 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Number.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-RichText.sitecore.ts +28 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/fields/Styleguide-FieldUsage-Text.sitecore.ts +28 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/graphql/GraphQL-ConnectedDemo.sitecore.ts +18 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/graphql/GraphQL-IntegratedDemo.sitecore.graphql +71 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/graphql/GraphQL-IntegratedDemo.sitecore.ts +25 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/graphql/GraphQL-Layout.sitecore.ts +15 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-ComponentParams.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-CustomRouteType.sitecore.ts +31 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Layout-Reuse.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Layout-Tabs-Tab.sitecore.ts +23 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Layout-Tabs.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Layout.sitecore.ts +15 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Multilingual.sitecore.ts +26 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-RouteFields.sitecore.ts +22 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Section.sitecore.ts +16 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-SitecoreContext.sitecore.ts +19 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/components/styleguide/Styleguide-Tracking.sitecore.ts +19 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/config.js +5 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/content.sitecore.ts +117 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/dictionary.sitecore.ts +52 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/placeholders.sitecore.ts +21 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/routes.sitecore.ts +88 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/templates/Styleguide-ContentList-Template.sitecore.ts +12 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/templates/Styleguide-Explanatory-Component.sitecore.ts +20 -0
- package/dist/templates/nextjs-styleguide/sitecore/definitions/templates/Styleguide-ItemLink-Template.sitecore.ts +13 -0
- package/dist/templates/nextjs-styleguide/src/Navigation.tsx +41 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Checkbox.tsx +52 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-ContentList.tsx +58 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Custom.tsx +25 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Date.tsx +55 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-File.tsx +30 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Image.tsx +58 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-ItemLink.tsx +50 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Link.tsx +46 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Number.tsx +34 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-RichText.tsx +35 -0
- package/dist/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Text.tsx +43 -0
- package/dist/templates/nextjs-styleguide/src/components/graphql/GraphQL-ConnectedDemo.dynamic.graphql +69 -0
- package/dist/templates/nextjs-styleguide/src/components/graphql/GraphQL-ConnectedDemo.dynamic.tsx +148 -0
- package/dist/templates/nextjs-styleguide/src/components/graphql/GraphQL-IntegratedDemo.tsx +130 -0
- package/dist/templates/nextjs-styleguide/src/components/graphql/GraphQL-Layout.tsx +37 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-ComponentParams.tsx +47 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-CustomRouteType.tsx +37 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Layout-Reuse.tsx +45 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Layout-Tabs-Tab.tsx +41 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Layout-Tabs.tsx +111 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Layout.tsx +68 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Multilingual.tsx +50 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-RouteFields.tsx +37 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Section.tsx +22 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-SitecoreContext.tsx +25 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Specimen.tsx +41 -0
- package/dist/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Tracking.tsx +341 -0
- package/dist/templates/nextjs-styleguide/src/lib/component-props/styleguide.ts +11 -0
- package/dist/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js +43 -0
- package/dist/templates/nextjs-styleguide/src/lib/next-config/plugins/styleguide.js +10 -0
- package/dist/templates/nextjs-styleguide/src/lib/sitemap-fetcher/plugins/disconnectedSitemapService.ts +46 -0
- package/dist/templates/nextjs-styleguide/src/pages/_app.tsx +33 -0
- package/package.json +61 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# This file contains a GraphQL query that will be executed and the result provided to
|
|
2
|
+
# your JSS component. You can run this query in GraphiQL ($endpoint/ui) for a nice editing experience.
|
|
3
|
+
|
|
4
|
+
# Note that we're executing _two queries_ (datasource and contextItem)
|
|
5
|
+
# within the context of the IntegratedDemoQuery _operation_. This makes it
|
|
6
|
+
# very efficient at gathering data from multiple sources.
|
|
7
|
+
|
|
8
|
+
query IntegratedDemoQuery($datasource: String!, $contextItem: String!, $language: String!) {
|
|
9
|
+
# Datasource query
|
|
10
|
+
# $datasource will always be set to the ID of the rendering's datasource item
|
|
11
|
+
# (as long as the GraphQLData helper is used)
|
|
12
|
+
datasource: item(path: $datasource, language: $language) {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
# Strongly-typed querying on known templates is possible!
|
|
16
|
+
...on <%- appPrefix ? `${helper.getPascalCaseName(appName)}` : "" %>GraphQLIntegratedDemo {
|
|
17
|
+
# Single-line text field
|
|
18
|
+
sample1 {
|
|
19
|
+
# the 'jsonValue' field is a JSON blob that represents the object that
|
|
20
|
+
# should be passed to JSS field rendering helpers (i.e. text, image, link)
|
|
21
|
+
jsonValue
|
|
22
|
+
value
|
|
23
|
+
}
|
|
24
|
+
# General Link field
|
|
25
|
+
sample2 {
|
|
26
|
+
jsonValue
|
|
27
|
+
# Structured querying of the field's values is possible
|
|
28
|
+
text
|
|
29
|
+
target
|
|
30
|
+
url
|
|
31
|
+
# Access to the template definition is possible
|
|
32
|
+
definition {
|
|
33
|
+
type
|
|
34
|
+
shared
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Context/route item query
|
|
41
|
+
# $contextItem will always be set to the ID of the current context item (the route item)
|
|
42
|
+
# (as long as the GraphQLData helper is used)
|
|
43
|
+
contextItem: item(path: $contextItem, language: $language) {
|
|
44
|
+
id
|
|
45
|
+
# Get the page title from the app route template
|
|
46
|
+
...on <%- appPrefix ? `${helper.getPascalCaseName(appName)}` : "" %>AppRoute {
|
|
47
|
+
pageTitle {
|
|
48
|
+
value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# List the children of the current route
|
|
53
|
+
children(hasLayout: true) {
|
|
54
|
+
results {
|
|
55
|
+
id
|
|
56
|
+
# typing fragments can be used anywhere!
|
|
57
|
+
# so in this case, we're grabbing the 'pageTitle'
|
|
58
|
+
# field on all child route items.
|
|
59
|
+
...on <%- appPrefix ? `${helper.getPascalCaseName(appName)}` : "" %>AppRoute {
|
|
60
|
+
pageTitle {
|
|
61
|
+
jsonValue
|
|
62
|
+
value
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
url{
|
|
66
|
+
path
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
const query = fs.readFileSync(
|
|
5
|
+
'sitecore/definitions/components/graphql/GraphQL-IntegratedDemo.sitecore.graphql',
|
|
6
|
+
'utf8'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Adds the GraphQL-IntegratedDemo component to the disconnected manifest.
|
|
11
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
12
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
13
|
+
*/
|
|
14
|
+
export default function GraphQLIntegratedDemo(manifest: Manifest): void {
|
|
15
|
+
manifest.addComponent({
|
|
16
|
+
name: 'GraphQL-IntegratedDemo',
|
|
17
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>GraphQL-IntegratedDemo',
|
|
18
|
+
icon: SitecoreIcon.GraphConnection_directed,
|
|
19
|
+
graphQLQuery: query,
|
|
20
|
+
fields: [
|
|
21
|
+
{ name: 'sample1', type: CommonFieldTypes.SingleLineText },
|
|
22
|
+
{ name: 'sample2', type: CommonFieldTypes.GeneralLink },
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the GraphQL-Layout component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function GraphQLLayout(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'GraphQL-Layout',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>GraphQL-Layout',
|
|
12
|
+
icon: SitecoreIcon.Layout,
|
|
13
|
+
placeholders: ['<%- helper.getAppPrefix(appPrefix, appName) %>jss-graphql-layout'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-ComponentParams component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideComponentParams(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-ComponentParams',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-ComponentParams',
|
|
12
|
+
icon: SitecoreIcon.WindowDialog,
|
|
13
|
+
params: ['cssClass', 'columns', 'useCallToAction'],
|
|
14
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
15
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
16
|
+
inherits: [
|
|
17
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-CustomRouteType component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideCustomRouteType(manifest: Manifest): void {
|
|
9
|
+
// This registers the custom route type with the manifest.
|
|
10
|
+
// Like a component, a route type contains data fields -
|
|
11
|
+
// but unlike a component, the fields are shared at the route level,
|
|
12
|
+
// instead of at the component level. This is good for scenarios such as
|
|
13
|
+
// article sections, where you may wish to use route-level fields for
|
|
14
|
+
// _sorting and filtering_ (it's difficult to query on component-level field data).
|
|
15
|
+
manifest.addRouteType({
|
|
16
|
+
name: '<%- helper.getAppPrefix(appPrefix, appName) %>ExampleCustomRouteType',
|
|
17
|
+
fields: [
|
|
18
|
+
{ name: 'headline', type: CommonFieldTypes.SingleLineText },
|
|
19
|
+
{ name: 'author', type: CommonFieldTypes.SingleLineText },
|
|
20
|
+
{ name: 'content', type: CommonFieldTypes.RichText },
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// We're also adding a component, that we can put on our sample custom route type route.
|
|
25
|
+
// This component will display the route level fields on the custom route type.
|
|
26
|
+
manifest.addComponent({
|
|
27
|
+
name: 'Styleguide-CustomRouteType',
|
|
28
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-CustomRouteType',
|
|
29
|
+
icon: SitecoreIcon.DocumentTag,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Layout-Reuse component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideLayoutReuse(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Layout-Reuse',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Layout-Reuse',
|
|
12
|
+
icon: SitecoreIcon.DocumentsExchange,
|
|
13
|
+
placeholders: ['<%- helper.getAppPrefix(appPrefix, appName) %>jss-reuse-example'],
|
|
14
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
15
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
16
|
+
inherits: [
|
|
17
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Layout-Tabs-Tab component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideLayoutTabsTab(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Layout-Tabs-Tab',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Layout-Tabs-Tab',
|
|
12
|
+
icon: SitecoreIcon.TabPane,
|
|
13
|
+
fields: [
|
|
14
|
+
{ name: 'title', type: CommonFieldTypes.SingleLineText },
|
|
15
|
+
{ name: 'content', type: CommonFieldTypes.RichText },
|
|
16
|
+
],
|
|
17
|
+
/*
|
|
18
|
+
If the component implementation uses <Placeholder> or withPlaceholder to expose a placeholder,
|
|
19
|
+
register it here, or components added to that placeholder will not be returned by Sitecore:
|
|
20
|
+
placeholders: ['exposed-placeholder-name']
|
|
21
|
+
*/
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Layout-Tabs component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideLayoutTabs(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Layout-Tabs',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Layout-Tabs',
|
|
12
|
+
icon: SitecoreIcon.DocumentTag,
|
|
13
|
+
placeholders: ['<%- helper.getAppPrefix(appPrefix, appName) %>jss-tabs'],
|
|
14
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
15
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
16
|
+
inherits: [
|
|
17
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Layout component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideLayout(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Layout',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Layout',
|
|
12
|
+
icon: SitecoreIcon.Layout,
|
|
13
|
+
placeholders: ['<%- helper.getAppPrefix(appPrefix, appName) %>jss-styleguide-layout'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Multilingual component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideMultilingual(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Multilingual',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Multilingual',
|
|
12
|
+
icon: SitecoreIcon.FlagGeneric,
|
|
13
|
+
fields: [
|
|
14
|
+
{
|
|
15
|
+
name: 'sample',
|
|
16
|
+
type: CommonFieldTypes.SingleLineText,
|
|
17
|
+
displayName: 'This field has a translated value',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
21
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
22
|
+
inherits: [
|
|
23
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-RouteFields component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideRouteFields(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-RouteFields',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-RouteFields',
|
|
12
|
+
icon: SitecoreIcon.TextField,
|
|
13
|
+
// this component gets all of its fields from the _route_,
|
|
14
|
+
// so it does not need any local fields defined.
|
|
15
|
+
|
|
16
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
17
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
18
|
+
inherits: [
|
|
19
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Section component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideSection(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Section',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Section',
|
|
12
|
+
icon: SitecoreIcon.DocumentTag,
|
|
13
|
+
fields: [{ name: 'heading', type: CommonFieldTypes.SingleLineText }],
|
|
14
|
+
placeholders: ['<%- helper.getAppPrefix(appPrefix, appName) %>jss-styleguide-section'],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-SitecoreContext component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideSitecoreContext(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-SitecoreContext',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-SitecoreContext',
|
|
12
|
+
icon: SitecoreIcon.ControlPanel,
|
|
13
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
14
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
15
|
+
inherits: [
|
|
16
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the Styleguide-Tracking component to the disconnected manifest.
|
|
5
|
+
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
|
|
6
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
7
|
+
*/
|
|
8
|
+
export default function StyleguideTracking(manifest: Manifest): void {
|
|
9
|
+
manifest.addComponent({
|
|
10
|
+
name: 'Styleguide-Tracking',
|
|
11
|
+
templateName: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-Tracking',
|
|
12
|
+
icon: SitecoreIcon.Compass,
|
|
13
|
+
// inherit fields from another template (../templates/Styleguide-Explanatory-Component)
|
|
14
|
+
// inheritance adds fields defined on the base template(s) implicitly to this component
|
|
15
|
+
inherits: [
|
|
16
|
+
'<%- helper.getAppPrefix(appPrefix, appName) %>styleguide-explanatory-component-template',
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// this file is imported by default prior to executing the jss manifest command
|
|
2
|
+
// use this to enable transpilation or any other pre-manifest configurations that are needed.
|
|
3
|
+
console.log('Enabling TypeScript transpilation for the manifest...');
|
|
4
|
+
// eslint-disable-next-line
|
|
5
|
+
require('ts-node').register({ project: 'tsconfig.scripts.json' });
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeFs,
|
|
3
|
+
MergeFsResult,
|
|
4
|
+
Manifest,
|
|
5
|
+
ItemDefinition,
|
|
6
|
+
} from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adds non-route content items to the disconnected manifest.
|
|
12
|
+
* Content items are conventionally defined in /data/content, similar to route items.
|
|
13
|
+
* This function is invoked by convention (*.sitecore.js) when `jss manifest` is run.
|
|
14
|
+
* @param {Manifest} manifest
|
|
15
|
+
* @returns {Promise}
|
|
16
|
+
*/
|
|
17
|
+
export default function addContentToManifest(manifest: Manifest): Promise<void> {
|
|
18
|
+
const rootItemName = 'Content';
|
|
19
|
+
const startPath = './data/content'; // relative to process invocation (i.e. where package.json lives)
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(startPath)) return Promise.resolve();
|
|
22
|
+
|
|
23
|
+
return mergeFs(startPath)
|
|
24
|
+
.then((result) => {
|
|
25
|
+
const items = convertToItems(
|
|
26
|
+
result,
|
|
27
|
+
path.resolve(startPath),
|
|
28
|
+
rootItemName,
|
|
29
|
+
manifest.language
|
|
30
|
+
);
|
|
31
|
+
return items;
|
|
32
|
+
})
|
|
33
|
+
.then((contentData) => {
|
|
34
|
+
if (contentData) {
|
|
35
|
+
manifest.addContent(contentData);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Maps filesystem content data into manifest content item data.
|
|
42
|
+
* @param {MergeFsResult} data Filesystem data (files and folders under current path)
|
|
43
|
+
* @param {string} basePath The base physical path to calculate relative item paths from
|
|
44
|
+
* @param {string} rootItemName Name of the root item to place non-content items under in Sitecore. Normally $siteRoot/Content.
|
|
45
|
+
* @param {string} language Language the manifest is being created in. Conventionally affects the expected filename.
|
|
46
|
+
* @returns {ItemDefinition}
|
|
47
|
+
*/
|
|
48
|
+
function convertToItems(
|
|
49
|
+
data: MergeFsResult,
|
|
50
|
+
basePath: string,
|
|
51
|
+
rootItemName: string,
|
|
52
|
+
language: string
|
|
53
|
+
): ItemDefinition {
|
|
54
|
+
const itemPath = convertPhsyicalPathToItemRelativePath(data.path, basePath);
|
|
55
|
+
const name = itemPath.substr(itemPath.lastIndexOf('/') + 1);
|
|
56
|
+
|
|
57
|
+
let result;
|
|
58
|
+
|
|
59
|
+
const contentItemPattern = new RegExp(`^${language}\\.(yaml|yml|json)$`, 'i');
|
|
60
|
+
|
|
61
|
+
const contentFileData = data.files.find((f) => contentItemPattern.test(f.filename));
|
|
62
|
+
|
|
63
|
+
if (contentFileData && contentFileData.contents) {
|
|
64
|
+
// the path has a valid content item definition
|
|
65
|
+
result = contentFileData.contents;
|
|
66
|
+
|
|
67
|
+
// Set the path to the item when imported in Sitecore.
|
|
68
|
+
// NOTE: Importing to any Sitecore path the import user has rights to is allowed; '$site/Content' is a convention only.
|
|
69
|
+
result.path = itemPath;
|
|
70
|
+
|
|
71
|
+
// content item name defaults to parent folder name if not explicit
|
|
72
|
+
if (!result.name) {
|
|
73
|
+
result.name = name;
|
|
74
|
+
}
|
|
75
|
+
} else if (data.folders.length > 0) {
|
|
76
|
+
// The path does not have a content item definition (i.e. en.yml),
|
|
77
|
+
// but it does have child folders (which may contain valid content items)
|
|
78
|
+
// it will be defined as a Folder item in Sitecore.
|
|
79
|
+
result = {
|
|
80
|
+
path: itemPath,
|
|
81
|
+
name: name || rootItemName,
|
|
82
|
+
displayName: name || rootItemName,
|
|
83
|
+
template: 'Folder',
|
|
84
|
+
children: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// recursively process child paths
|
|
89
|
+
if (data.folders.length > 0) {
|
|
90
|
+
result.children = data.folders
|
|
91
|
+
.map((folder) => convertToItems(folder, basePath, rootItemName, language))
|
|
92
|
+
.filter((item) => item); // remove null results
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Converts a physical filesystem path into a relative Sitecore item path.
|
|
100
|
+
* i.e. if physicalPath = /var/log and basePath = /var, this returns /log.
|
|
101
|
+
* @param {string} physicalPath
|
|
102
|
+
* @param {string} basePath
|
|
103
|
+
*/
|
|
104
|
+
function convertPhsyicalPathToItemRelativePath(physicalPath: string, basePath: string) {
|
|
105
|
+
const targetPathSeparator = '/';
|
|
106
|
+
|
|
107
|
+
// normalize path separators to /
|
|
108
|
+
const normalizedPath = physicalPath.replace(basePath, '').replace(/\\/g, targetPathSeparator);
|
|
109
|
+
|
|
110
|
+
if (!normalizedPath) {
|
|
111
|
+
return targetPathSeparator;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return normalizedPath.indexOf(targetPathSeparator) > 0
|
|
115
|
+
? `${targetPathSeparator}${normalizedPath}`
|
|
116
|
+
: normalizedPath;
|
|
117
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Manifest, mergeFs, MergeFsResult } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reads dictionary definition file in /data/dictionary,
|
|
6
|
+
* then emits the dictionary into the disconnected manifest.
|
|
7
|
+
* Invoked by convention (*.sitecore.js) when `jss manifest` is run.
|
|
8
|
+
* @param {Manifest} manifest
|
|
9
|
+
* @returns {Promise}
|
|
10
|
+
*/
|
|
11
|
+
export default function addDictionaryToManifest(
|
|
12
|
+
manifest: Manifest
|
|
13
|
+
): Promise<void> | void | undefined {
|
|
14
|
+
const startPath = './data/dictionary'; // relative to process invocation (i.e. where package.json lives)
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(startPath)) return;
|
|
17
|
+
|
|
18
|
+
return mergeFs(startPath)
|
|
19
|
+
.then((result) => mergeDictionaryFiles(result, manifest.language))
|
|
20
|
+
.then((mergedDictionary) => convertToManifestDictionary(mergedDictionary))
|
|
21
|
+
.then((dictionary) => manifest.addDictionary(...dictionary));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function convertToManifestDictionary(mergedDictionary: { [key: string]: string }) {
|
|
25
|
+
return Object.keys(mergedDictionary).map((key) => ({
|
|
26
|
+
key,
|
|
27
|
+
value: mergedDictionary[key],
|
|
28
|
+
// optional: if you wished to specify the exact ID of a dictionary item when imported,
|
|
29
|
+
// you could pass an 'id' property here that was a GUID or unique (app-wide) string
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Maps a filesystem dictionary file into an object that represents the dictionary.
|
|
35
|
+
* @param {MergeFsResult} data Filesystem data (files and folders under current path)
|
|
36
|
+
* @param {string} language Language the manifest is being created in. Conventionally affects the expected filename.
|
|
37
|
+
* @returns {object} Key-value mappings for the dictionary
|
|
38
|
+
*/
|
|
39
|
+
function mergeDictionaryFiles(data: MergeFsResult, language: string) {
|
|
40
|
+
let dictionaryResult = {};
|
|
41
|
+
|
|
42
|
+
// regex that matches the expected dictionary file name
|
|
43
|
+
const dictionaryFilePattern = new RegExp(`^${language}\\.(yaml|yml|json)$`, 'i');
|
|
44
|
+
const dictionaryFileData = data.files.find((f) => dictionaryFilePattern.test(f.filename));
|
|
45
|
+
|
|
46
|
+
if (dictionaryFileData && dictionaryFileData.contents) {
|
|
47
|
+
// customize here to modify the dictionary or apply conventions
|
|
48
|
+
dictionaryResult = dictionaryFileData.contents;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return dictionaryResult;
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adding placeholders is optional but allows setting a user-friendly display name. Placeholder Settings
|
|
5
|
+
* items will be created for any placeholders explicitly added, or discovered in your routes and component definitions.
|
|
6
|
+
* Invoked by convention (*.sitecore.js) when `jss manifest` is run.
|
|
7
|
+
* @param {Manifest} manifest
|
|
8
|
+
*/
|
|
9
|
+
export default function addPlaceholdersToManifest(manifest: Manifest): void {
|
|
10
|
+
manifest.addPlaceholder(
|
|
11
|
+
{ name: '<%- helper.getAppPrefix(appPrefix, appName) %>jss-main', displayName: 'Main' },
|
|
12
|
+
// you can optionally pass a GUID or unique (app-wide) string as an ID
|
|
13
|
+
// this will inform the ID that is set when imported into Sitecore.
|
|
14
|
+
// If the ID is not set, an ID is created based on the placeholder name.
|
|
15
|
+
{
|
|
16
|
+
name: '<%- helper.getAppPrefix(appPrefix, appName) %>jss-tabs',
|
|
17
|
+
displayName: 'Tabs',
|
|
18
|
+
id: 'tabs-placeholder',
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import {
|
|
3
|
+
Manifest,
|
|
4
|
+
RouteDefinition,
|
|
5
|
+
CommonFieldTypes,
|
|
6
|
+
mergeFs,
|
|
7
|
+
MergeFsResult,
|
|
8
|
+
} from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Collects the disconnected routes defined in data/routes into the manifest.
|
|
12
|
+
* Invoked by convention (*.sitecore.js) when `jss manifest` is run.
|
|
13
|
+
* Alter this method if you wish to store disconnected route data in some way other than the default,
|
|
14
|
+
* or to preprocess the route data before it is sent to Sitecore to be ingested - for example to add fields to the route type.
|
|
15
|
+
* @param {Manifest} manifest The manifest instance to add routes to
|
|
16
|
+
* @returns {Promise}
|
|
17
|
+
*/
|
|
18
|
+
export default function addRoutesToManifest(manifest: Manifest): Promise<void> {
|
|
19
|
+
// Configure the default route type for the app
|
|
20
|
+
// this lets us enable route-level data fields,
|
|
21
|
+
// which most apps will want for metadata like page titles, SEO metas, or OpenGraph.
|
|
22
|
+
// You can add additional non-default route types using `manifest.addRouteType()`,
|
|
23
|
+
// which routes can use by setting `template: YourCustomRouteTypeName` in their definition.
|
|
24
|
+
const appTemplateSection = 'Page Metadata';
|
|
25
|
+
|
|
26
|
+
manifest.setDefaultRouteType({
|
|
27
|
+
name: '<%- helper.getAppPrefix(appPrefix, appName) %>App Route',
|
|
28
|
+
displayName: 'App Route',
|
|
29
|
+
fields: [
|
|
30
|
+
{
|
|
31
|
+
name: 'pageTitle',
|
|
32
|
+
displayName: 'Page Title',
|
|
33
|
+
section: appTemplateSection,
|
|
34
|
+
type: CommonFieldTypes.SingleLineText,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
insertOptions: ['<%- helper.getAppPrefix(appPrefix, appName) %>App Route'],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return mergeFs('./data/routes') // relative to process invocation (i.e. your package.json)
|
|
41
|
+
.then((result) => convertToRoutes(result, manifest.language))
|
|
42
|
+
.then((routeData) => {
|
|
43
|
+
manifest.addRoute(routeData);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Maps filesystem data into manifest route data.
|
|
49
|
+
* This is where custom conventions regarding route data would go.
|
|
50
|
+
* @param {MergeFsResult} data Filesystem data (files and folders under current path)
|
|
51
|
+
* @param {string} language Language the manifest is being created in. Conventionally affects the expected filename.
|
|
52
|
+
* @returns {RouteDefinition}
|
|
53
|
+
*/
|
|
54
|
+
function convertToRoutes(data: MergeFsResult, language: string): RouteDefinition {
|
|
55
|
+
let routeData;
|
|
56
|
+
|
|
57
|
+
// regex that matches the expected route file name
|
|
58
|
+
const routeFilePattern = new RegExp(`^${language}\\.(yaml|yml|json)$`, 'i');
|
|
59
|
+
|
|
60
|
+
// find the expected file in the list of files in the current folder
|
|
61
|
+
const routeFileData = data.files.find((f) => routeFilePattern.test(f.filename));
|
|
62
|
+
|
|
63
|
+
// parse the route data file contents
|
|
64
|
+
if (routeFileData && routeFileData.contents) {
|
|
65
|
+
routeData = routeFileData.contents;
|
|
66
|
+
|
|
67
|
+
if (!routeData.name) {
|
|
68
|
+
// no name = imply one from parent folder name
|
|
69
|
+
routeData.name = path.basename(path.dirname(routeFileData.path));
|
|
70
|
+
// special case for the home route item as its parent folder is 'routes'
|
|
71
|
+
if (routeData.name === 'routes') routeData.name = 'home';
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
console.warn(
|
|
75
|
+
`Route data file not found: ${data.path}\\${language}.(yaml|yml|json).
|
|
76
|
+
The route will not be added to the manifest. Empty folders can cause this warning.`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// recursively crawl child routes (folders)
|
|
81
|
+
if (routeData && data.folders.length > 0) {
|
|
82
|
+
routeData.children = data.folders
|
|
83
|
+
.map((folder) => convertToRoutes(folder, language))
|
|
84
|
+
.filter((route) => route); // remove null results
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return routeData;
|
|
88
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommonFieldTypes, Manifest } from '@sitecore-jss/sitecore-jss-dev-tools';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is the data template for an individual _item_ in the Styleguide's Content List field demo.
|
|
5
|
+
* @param {Manifest} manifest Manifest instance to add components to
|
|
6
|
+
*/
|
|
7
|
+
export default function StyleguideContentListItemTemplate(manifest: Manifest): void {
|
|
8
|
+
manifest.addTemplate({
|
|
9
|
+
name: '<%- helper.getAppPrefix(appPrefix, appName) %>Styleguide-ContentList-Item-Template',
|
|
10
|
+
fields: [{ name: 'textField', type: CommonFieldTypes.SingleLineText }],
|
|
11
|
+
});
|
|
12
|
+
}
|