Skip to content

added title meta tag #266

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

Merged
merged 5 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
128 changes: 64 additions & 64 deletions templates/next/components/foo/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ export const Form: FunctionComponent<Props> = ({ {{{lc}}} }) => {

return (
<div>
<div>
<div>
<Head>
<title>{{{lc}}} Form page</title>
{ {{{lc}}} ? <title>Edit {{{ucf}}} { {{{lc}}}['@id'] }</title> : <title>Create {{{ucf}}}</title>}
<meta property="og:title" content="Form page" key="title" />
</Head>
</div>
{ {{{lc}}} ? <h1>Edit {{{ucf}}} { {{{lc}}}['@id'] }</h1> : <h1>Create {{{ucf}}}</h1>}
<Formik
initialValues={ {{~lc}} ? {...{{lc~}} } : new {{{ucf}}}()}
validate={(values) => {
const errors = {};
// add your validation logic here
{ {{{lc}}} ? <h1>Edit {{{ucf}}} { {{{lc}}}['@id'] }</h1> : <h1>Create {{{ucf}}}</h1>}
<Formik
initialValues={ {{~lc}} ? {...{{lc~}} } : new {{{ucf}}}()}
validate={(values) => {
const errors = {};
// add your validation logic here
return errors;
}}
onSubmit={async (values, { setSubmitting, setStatus }) => {
}}
onSubmit={async (values, { setSubmitting, setStatus }) => {
const isCreation = !values["@id"];
try {
await fetch(isCreation ? "/{{{name}}}" : values["@id"], {
Expand All @@ -60,24 +60,24 @@ export const Form: FunctionComponent<Props> = ({ {{{lc}}} }) => {
msg: `Error when ${isCreation ? 'creating': 'updating'} the resource.`,
});
}
setSubmitting(false);
}}
>
{({
values,
setSubmitting(false);
}}
>
{({
values,
status,
errors,
touched,
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
}) => (
<form onSubmit={handleSubmit}>
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
}) => (
<form onSubmit={handleSubmit}>
{{#each formFields}}
<div className="form-group">
<label className="form-control-label" htmlFor="{{lc}}_{{name}}">{{name}}</label>
<input
<div className="form-group">
<label className="form-control-label" htmlFor="{{lc}}_{{name}}">{{name}}</label>
<input
name="{{name}}"
id="{{lc}}_{{name}}"
value={ values.{{name}} ?? "" }
Expand All @@ -87,48 +87,48 @@ export const Form: FunctionComponent<Props> = ({ {{{lc}}} }) => {
{{#if required}}required={true}{{/if}}
className={`form-control${errors.{{name}} && touched.{{name}} ? ' is-invalid' : ''}`}
aria-invalid={errors.{{name}} && touched.{{name~}} }
onChange={handleChange}
onBlur={handleBlur}
/>
</div>
{ errors.{{name}} && touched.{{name}} && <div className="invalid-feedback">{ errors.{{name}} }</div> }
onChange={handleChange}
onBlur={handleBlur}
/>
</div>
{ errors.{{name}} && touched.{{name}} && <div className="invalid-feedback">{ errors.{{name}} }</div> }
{{/each}}

{status && status.msg && (
<div
className={`alert ${
status.isValid ? "alert-success" : "alert-danger"
}`}
role="alert"
>
{status.msg}
</div>
)}
{status && status.msg && (
<div
className={`alert ${
status.isValid ? "alert-success" : "alert-danger"
}`}
role="alert"
>
{status.msg}
</div>
)}

{error && (
<div className="alert alert-danger" role="alert">
{error}
</div>
)}
{error && (
<div className="alert alert-danger" role="alert">
{error}
</div>
)}

<button
type="submit"
className="btn btn-success"
disabled={isSubmitting}
>
Submit
</button>
</form>
)}
</Formik>
<Link href="/{{{name}}}">
<a className="btn btn-primary">Back to list</a>
</Link>
{ {{{lc}}} && (
<button className="btn btn-danger" onClick={handleDelete}>
<a>Delete</a>
</button>
)}
</div>
);
<button
type="submit"
className="btn btn-success"
disabled={isSubmitting}
>
Submit
</button>
</form>
)}
</Formik>
<Link href="/{{{name}}}">
<a className="btn btn-primary">Back to list</a>
</Link>
{ {{{lc}}} && (
<button className="btn btn-danger" onClick={handleDelete}>
<a>Delete</a>
</button>
)}
</div>
);
};
12 changes: 6 additions & 6 deletions templates/next/components/foo/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ interface Props {

export const List: FunctionComponent<Props> = ({ {{{name}}} }) => (
<div>
<div>
<Head>
<title>{{{lc}}} List page</title>
<meta property="og:title" content="List page" key="title" />
</Head>
</div>
<div>
<Head>
<title>{{{ucf}}} List</title>
<meta property="og:title" content="List page" key="title" />
</Head>
</div>
<h1>{{{ucf}}} List</h1>
<Link href="/{{{name}}}/create">
<a className="btn btn-primary">Create</a>
Expand Down
4 changes: 2 additions & 2 deletions templates/next/components/foo/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const Show: FunctionComponent<Props> = ({ {{{lc}}} }) => {

return (
<div>
<div>
<div>
<Head>
<title>{{{lc}}} Show page</title>
<title>Show { {{{lc}}}['@id'] }</title>
<meta property="og:title" content="Show page" key="title" />
</Head>
</div>
Expand Down