-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Personalize][Initializers] Move XP tracking API examples to separate…
… add-on initializer (#980) * [Personalize][Initializers] Move XP tracking API examples to separate add-on initializer * add empty line * refactoring * use common message * remove unused variable * Add type * add new line * formatting * Update packages/create-sitecore-jss/src/initializers/nextjs/index.ts Co-authored-by: Adam Brauer <400763+ambrauer@users.noreply.github.com>
- Loading branch information
1 parent
6f3f4d0
commit 7b1babd
Showing
21 changed files
with
596 additions
and
78 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
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
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
51 changes: 51 additions & 0 deletions
51
packages/create-sitecore-jss/src/initializers/nextjs-styleguide-tracking/index.ts
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,51 @@ | ||
import path, { sep } from 'path'; | ||
import { | ||
Initializer, | ||
openPackageJson, | ||
transform, | ||
DEFAULT_APPNAME, | ||
ClientAppArgs, | ||
missingAddonMsg, | ||
incompatibleAddonsMsg, | ||
} from '../../common'; | ||
|
||
export default class NextjsStyleguideInitializer implements Initializer { | ||
get isBase(): boolean { | ||
return false; | ||
} | ||
|
||
async init(args: ClientAppArgs) { | ||
const pkg = openPackageJson(`${args.destination}${sep}package.json`); | ||
|
||
const mergedArgs = { | ||
...args, | ||
appName: args.appName || pkg?.config?.appName || DEFAULT_APPNAME, | ||
appPrefix: args.appPrefix || pkg?.config?.prefix || false, | ||
}; | ||
|
||
const templatePath = path.resolve(__dirname, '../../templates/nextjs-styleguide-tracking'); | ||
|
||
await transform(templatePath, mergedArgs); | ||
|
||
if ( | ||
!args.templates.includes('nextjs-styleguide') && | ||
!pkg.config?.templates?.includes('nextjs-styleguide') | ||
) { | ||
console.log(missingAddonMsg('nextjs-styleguide-tracking', 'nextjs-styleguide')); | ||
} | ||
|
||
if ( | ||
args.templates.includes('nextjs-personalize') || | ||
pkg.config?.templates?.includes('nextjs-personalize') | ||
) { | ||
console.log(incompatibleAddonsMsg('nextjs-styleguide-tracking', 'nextjs-personalize')); | ||
} | ||
|
||
const response = { | ||
nextSteps: [], | ||
appName: mergedArgs.appName, | ||
}; | ||
|
||
return response; | ||
} | ||
} |
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
51 changes: 0 additions & 51 deletions
51
packages/create-sitecore-jss/src/templates/nextjs-personalize/src/Layout.tsx
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
packages/create-sitecore-jss/src/templates/nextjs-personalize/src/Scripts.tsx
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,11 @@ | ||
import CdpIntegrationScript from 'components/CdpIntegrationScript'; | ||
|
||
const Scripts = (): JSX.Element => { | ||
return ( | ||
<> | ||
<CdpIntegrationScript /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Scripts; |
5 changes: 5 additions & 0 deletions
5
packages/create-sitecore-jss/src/templates/nextjs-styleguide-tracking/data/dictionary/en.yml
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,5 @@ | ||
styleguide-sample: This is a dictionary entry in English as a demonstration | ||
Documentation: Documentation | ||
Styleguide: Styleguide | ||
GraphQL: GraphQL | ||
Tracking: Tracking |
8 changes: 8 additions & 0 deletions
8
.../create-sitecore-jss/src/templates/nextjs-styleguide-tracking/data/routes/tracking/en.yml
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 @@ | ||
fields: | ||
pageTitle: Styleguide Tracking | Sitecore JSS | ||
placeholders: | ||
<%- helper.getAppPrefix(appPrefix, appName) %>jss-main: | ||
- componentName: Styleguide-Tracking | ||
fields: | ||
heading: Tracking | ||
description: <p><small>JSS supports tracking Sitecore analytics events from within apps. Give it a try with this handy interactive demo.</small></p> |
File renamed without changes.
Oops, something went wrong.