Skip to content

Commit eef2629

Browse files
refacto: moved title meta tag in pages (#278)
* refacto: moved title meta tag in pages * fixed typo in imports * removed og:title from Head
1 parent 14ffb7b commit eef2629

File tree

7 files changed

+40
-27
lines changed

7 files changed

+40
-27
lines changed

templates/next/components/foo/Form.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { FunctionComponent, useState } from "react";
22
import Link from "next/link";
33
import { useRouter } from "next/router";
4-
import Head from "next/head";
54
import { ErrorMessage, Formik } from "formik";
65
import { fetch } from "../../utils/dataAccess";
76
import { {{{ucf}}} } from '../../types/{{{ucf}}}';
@@ -28,12 +27,6 @@ export const Form: FunctionComponent<Props> = ({ {{{lc}}} }) => {
2827

2928
return (
3029
<div>
31-
<div>
32-
<Head>
33-
<title>{ {{{lc}}} ? `Edit {{{ucf}}} ${ {{~lc}}['@id']}` : `Create {{{ucf}}}` }</title>
34-
<meta property="og:title" content={ {{{lc}}} ? `Edit {{{ucf}}} ${ {{~lc}}['@id']}` : `Create {{{ucf}}}` } />
35-
</Head>
36-
</div>
3730
<h1>{ {{{lc}}} ? `Edit {{{ucf}}} ${ {{~lc}}['@id']}` : `Create {{{ucf}}}` }</h1>
3831
<Formik
3932
initialValues={ {{~lc}} ? {...{{lc~}} } : new {{{ucf}}}()}

templates/next/components/foo/List.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { FunctionComponent } from "react";
22
import Link from "next/link";
3-
import Head from "next/head";
43
import ReferenceLinks from "../../components/common/ReferenceLinks";
54
import { {{{ucf}}} } from '../../types/{{{ucf}}}';
65

@@ -10,12 +9,6 @@ interface Props {
109

1110
export const List: FunctionComponent<Props> = ({ {{{name}}} }) => (
1211
<div>
13-
<div>
14-
<Head>
15-
<title>{{{ucf}}} List</title>
16-
<meta property="og:title" content="{{{ucf}}} List" key="title" />
17-
</Head>
18-
</div>
1912
<h1>{{{ucf}}} List</h1>
2013
<Link href="/{{{name}}}/create">
2114
<a className="btn btn-primary">Create</a>

templates/next/components/foo/Show.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { FunctionComponent, useState } from 'react';
22
import Link from 'next/link';
3-
import Head from "next/head";
43
import { useRouter } from "next/router";
54
import { fetch } from "../../utils/dataAccess";
6-
import { ReferenceLinks } from '../common/ReferenceLinks';
5+
import ReferenceLinks from '../common/ReferenceLinks';
76
import { {{{ucf}}} } from '../../types/{{{ucf}}}';
87

98
interface Props {
@@ -28,12 +27,6 @@ export const Show: FunctionComponent<Props> = ({ {{{lc}}} }) => {
2827

2928
return (
3029
<div>
31-
<div>
32-
<Head>
33-
<title>{`Show {{{ucf}}} ${ {{~lc}}['@id']}`}</title>
34-
<meta property="og:title" content={`Show {{{ucf}}} ${ {{~lc}}['@id']}`} key="title" />
35-
</Head>
36-
</div>
3730
<h1>{`Show {{{ucf}}} ${ {{~lc}}['@id']}`}</h1>
3831
<table className="table table-responsive table-striped table-hover">
3932
<thead>

templates/next/pages/foos/[id]/edit.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ import { NextComponentType, NextPageContext } from 'next';
22
import { Form } from '../../../components/{{{lc}}}/Form';
33
import { {{{ucf}}} } from '../../../types/{{{ucf}}}';
44
import { fetch } from '../../../utils/dataAccess';
5+
import Head from "next/head";
56

67
interface Props {
78
{{{lc}}}: {{{ucf}}};
89
};
910

1011
const Page: NextComponentType<NextPageContext, Props, Props> = ({ {{{lc}}} }) => {
11-
1212
return (
13-
<Form {{{lc}}}={ {{{lc}}} }/>
13+
<div>
14+
<div>
15+
<Head>
16+
<title>{ {{{lc}}} && `Edit {{{ucf}}} ${ {{~lc}}['@id']}`}</title>
17+
</Head>
18+
</div>
19+
<Form {{{lc}}}={ {{{lc}}} }/>
20+
</div>
1421
);
1522
};
1623

templates/next/pages/foos/[id]/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ import { NextComponentType, NextPageContext } from 'next';
22
import { Show } from '../../../components/{{{lc}}}/Show';
33
import { {{{ucf}}} } from '../../../types/{{{ucf}}}';
44
import { fetch } from '../../../utils/dataAccess';
5+
import Head from "next/head";
56

67
interface Props {
78
{{{lc}}}: {{{ucf}}};
89
};
910

1011
const Page: NextComponentType<NextPageContext, Props, Props> = ({ {{{lc}}} }) => {
1112
return (
12-
<Show {{{lc}}}={ {{{lc}}} }/>
13+
<div>
14+
<div>
15+
<Head>
16+
<title>{`Show {{{ucf}}} ${ {{~lc}}['@id']}`}</title>
17+
</Head>
18+
</div>
19+
<Show {{{lc}}}={ {{{lc}}} }/>
20+
</div>
1321
);
1422
};
1523

templates/next/pages/foos/create.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import { NextComponentType, NextPageContext } from "next";
22
import { Form } from "../../components/{{{lc}}}/Form";
3+
import Head from "next/head";
4+
5+
const Page: NextComponentType<NextPageContext> = () => (
6+
<div>
7+
<div>
8+
<Head>
9+
<title>Create {{{ucf}}} </title>
10+
</Head>
11+
</div>
12+
<Form />
13+
</div>
14+
)
315

4-
const Page: NextComponentType<NextPageContext> = () => <Form />;
516

617
export default Page;

templates/next/pages/foos/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import { List } from '../../components/{{{lc}}}/List';
33
import { PagedCollection } from '../../types/Collection';
44
import { {{{ucf}}} } from '../../types/{{{ucf}}}';
55
import { fetch } from '../../utils/dataAccess';
6+
import Head from "next/head";
67

78
interface Props {
89
collection: PagedCollection<{{{ucf}}}>;
910
}
1011

1112
const Page: NextComponentType<NextPageContext, Props, Props> = ({collection}) => (
12-
<List {{{name}}}={collection['{{{hydraPrefix}}}member']}/>
13+
<div>
14+
<div>
15+
<Head>
16+
<title>{{{ucf}}} List</title>
17+
</Head>
18+
</div>
19+
<List {{{name}}}={collection['{{{hydraPrefix}}}member']}/>
20+
</div>
1321
);
1422

1523
Page.getInitialProps = async () => {

0 commit comments

Comments
 (0)