Skip to content

Commit

Permalink
[Headless SXA] Nextjs-SXA empty add-on (#927)
Browse files Browse the repository at this point in the history
* add nextjs-sxa empty add-on

* removed package.json, added placeholder component

* changed placeholder component description
  • Loading branch information
addy-pathania authored Feb 15, 2022
1 parent b7b5055 commit cf11cfd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
39 changes: 39 additions & 0 deletions packages/create-sitecore-jss/src/initializers/nextjs-sxa/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import path from 'path';
import {
Initializer,
openPackageJson,
transform,
DEFAULT_APPNAME,
ClientAppArgs,
} from '../../common';

export default class NextjsSxaInitializer implements Initializer {
get isBase(): boolean {
return false;
}

async init(args: ClientAppArgs) {
const pkg = openPackageJson(`${args.destination}\\package.json`);

// TODO: prompts for SXA
// const answers = await prompt<StyleguideAnswer>(styleguidePrompts, args);

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-sxa');

await transform(templatePath, mergedArgs);

const response = {
// TODO: next steps
nextSteps: [],
appName: mergedArgs.appName,
};

return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class NextjsInitializer implements Initializer {
type: 'checkbox',
name: 'addInitializers',
message: 'Would you like to include any add-on initializers?',
choices: ['nextjs-styleguide'],
choices: ['nextjs-styleguide', 'nextjs-sxa'],
});
addInitializers = addInitAnswer.addInitializers;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* A simple placeholder component.
*/
const HelloWorld = (): JSX.Element => (
<div className="contentBlock">
<p>Hello World</p>
</div>
);

export default HelloWorld;

0 comments on commit cf11cfd

Please sign in to comment.