Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Headless SXA] Nextjs-SXA empty add-on #927

Merged
merged 3 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;