diff --git a/src/features/api/apiClient.ts b/src/features/api/apiClient.ts index 04c6a736..2f5225f9 100644 --- a/src/features/api/apiClient.ts +++ b/src/features/api/apiClient.ts @@ -8,6 +8,7 @@ import { ProjectspageApi, } from './strapi'; import { AboutpageApi } from './strapi/apis/AboutpageApi'; +import { ContactpageApi } from './strapi/apis/ContactpageApi'; const configParams: ConfigurationParameters = { basePath: process.env.STRAPI_ENDPOINT, @@ -22,6 +23,7 @@ export const apiClient = { projectApi: new ProjectApi(apiConfig), aboutpageApi: new AboutpageApi(apiConfig), projectspageApi: new ProjectspageApi(apiConfig), + contactPageApi: new ContactpageApi(apiConfig), }; export type ApiClient = typeof apiClient; diff --git a/src/features/api/strapi/.openapi-generator/FILES b/src/features/api/strapi/.openapi-generator/FILES index f44ce3fb..7486e77c 100644 --- a/src/features/api/strapi/.openapi-generator/FILES +++ b/src/features/api/strapi/.openapi-generator/FILES @@ -3,6 +3,7 @@ apis/AboutpageApi.ts apis/ArticleApi.ts apis/CategoryApi.ts apis/CommentApi.ts +apis/ContactpageApi.ts apis/GlobalApi.ts apis/HomepageApi.ts apis/ProjectApi.ts @@ -15,6 +16,7 @@ models/AboutpageSeo.ts models/Article.ts models/Category.ts models/Comment.ts +models/Contactpage.ts models/Global.ts models/Homepage.ts models/HomepageHero.ts @@ -24,6 +26,7 @@ models/NewArticle.ts models/NewArticleComment.ts models/NewCategory.ts models/NewComment.ts +models/NewContactpage.ts models/NewGlobal.ts models/NewHomepage.ts models/NewProject.ts diff --git a/src/features/api/strapi/apis/ContactpageApi.ts b/src/features/api/strapi/apis/ContactpageApi.ts new file mode 100644 index 00000000..63c66d20 --- /dev/null +++ b/src/features/api/strapi/apis/ContactpageApi.ts @@ -0,0 +1,207 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DOCUMENTATION + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Contact: contact-email@something.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Contactpage, + ContactpageFromJSON, + ContactpageToJSON, + NewContactpage, + NewContactpageFromJSON, + NewContactpageToJSON, +} from '../models'; + +export interface ContactpageGetRequest { + limit?: number; + sort?: string; + start?: number; + ne?: string; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + containss?: string; + _in?: Array; + nin?: Array; +} + +export interface ContactpagePutRequest { + newContactpage: NewContactpage; +} + +/** + * + */ +export class ContactpageApi extends runtime.BaseAPI { + + /** + * Delete a single contactpage record + */ + async contactpageDeleteRaw(initOverrides?: RequestInit): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/contactpage`, + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Delete a single contactpage record + */ + async contactpageDelete(initOverrides?: RequestInit): Promise { + const response = await this.contactpageDeleteRaw(initOverrides); + return await response.value(); + } + + /** + * Find all the contactpage\'s records + */ + async contactpageGetRaw(requestParameters: ContactpageGetRequest, initOverrides?: RequestInit): Promise> { + const queryParameters: any = {}; + + if (requestParameters.limit !== undefined) { + queryParameters['_limit'] = requestParameters.limit; + } + + if (requestParameters.sort !== undefined) { + queryParameters['_sort'] = requestParameters.sort; + } + + if (requestParameters.start !== undefined) { + queryParameters['_start'] = requestParameters.start; + } + + if (requestParameters.ne !== undefined) { + queryParameters['_ne'] = requestParameters.ne; + } + + if (requestParameters.lt !== undefined) { + queryParameters['_lt'] = requestParameters.lt; + } + + if (requestParameters.lte !== undefined) { + queryParameters['_lte'] = requestParameters.lte; + } + + if (requestParameters.gt !== undefined) { + queryParameters['_gt'] = requestParameters.gt; + } + + if (requestParameters.gte !== undefined) { + queryParameters['_gte'] = requestParameters.gte; + } + + if (requestParameters.contains !== undefined) { + queryParameters['_contains'] = requestParameters.contains; + } + + if (requestParameters.containss !== undefined) { + queryParameters['_containss'] = requestParameters.containss; + } + + if (requestParameters._in) { + queryParameters['_in'] = requestParameters._in; + } + + if (requestParameters.nin) { + queryParameters['_nin'] = requestParameters.nin; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/contactpage`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ContactpageFromJSON(jsonValue)); + } + + /** + * Find all the contactpage\'s records + */ + async contactpageGet(requestParameters: ContactpageGetRequest, initOverrides?: RequestInit): Promise { + const response = await this.contactpageGetRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Update a single contactpage record + */ + async contactpagePutRaw(requestParameters: ContactpagePutRequest, initOverrides?: RequestInit): Promise> { + if (requestParameters.newContactpage === null || requestParameters.newContactpage === undefined) { + throw new runtime.RequiredError('newContactpage','Required parameter requestParameters.newContactpage was null or undefined when calling contactpagePut.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearerAuth", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/contactpage`, + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: NewContactpageToJSON(requestParameters.newContactpage), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ContactpageFromJSON(jsonValue)); + } + + /** + * Update a single contactpage record + */ + async contactpagePut(requestParameters: ContactpagePutRequest, initOverrides?: RequestInit): Promise { + const response = await this.contactpagePutRaw(requestParameters, initOverrides); + return await response.value(); + } + +} diff --git a/src/features/api/strapi/apis/index.ts b/src/features/api/strapi/apis/index.ts index be90c02e..4ebd914d 100644 --- a/src/features/api/strapi/apis/index.ts +++ b/src/features/api/strapi/apis/index.ts @@ -4,6 +4,7 @@ export * from './AboutpageApi'; export * from './ArticleApi'; export * from './CategoryApi'; export * from './CommentApi'; +export * from './ContactpageApi'; export * from './GlobalApi'; export * from './HomepageApi'; export * from './ProjectApi'; diff --git a/src/features/api/strapi/models/Contactpage.ts b/src/features/api/strapi/models/Contactpage.ts new file mode 100644 index 00000000..9edad1fe --- /dev/null +++ b/src/features/api/strapi/models/Contactpage.ts @@ -0,0 +1,88 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DOCUMENTATION + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Contact: contact-email@something.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import { + AboutpageSeo, + AboutpageSeoFromJSON, + AboutpageSeoFromJSONTyped, + AboutpageSeoToJSON, +} from './'; + +/** + * + * @export + * @interface Contactpage + */ +export interface Contactpage { + /** + * + * @type {string} + * @memberof Contactpage + */ + id: string; + /** + * + * @type {AboutpageSeo} + * @memberof Contactpage + */ + seo?: AboutpageSeo; + /** + * + * @type {string} + * @memberof Contactpage + */ + body?: string; + /** + * + * @type {Date} + * @memberof Contactpage + */ + publishedAt?: Date; +} + +export function ContactpageFromJSON(json: any): Contactpage { + return ContactpageFromJSONTyped(json, false); +} + +export function ContactpageFromJSONTyped(json: any, ignoreDiscriminator: boolean): Contactpage { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': json['id'], + 'seo': !exists(json, 'seo') ? undefined : AboutpageSeoFromJSON(json['seo']), + 'body': !exists(json, 'body') ? undefined : json['body'], + 'publishedAt': !exists(json, 'published_at') ? undefined : (new Date(json['published_at'])), + }; +} + +export function ContactpageToJSON(value?: Contactpage | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'seo': AboutpageSeoToJSON(value.seo), + 'body': value.body, + 'published_at': value.publishedAt === undefined ? undefined : (value.publishedAt.toISOString()), + }; +} + + diff --git a/src/features/api/strapi/models/NewContactpage.ts b/src/features/api/strapi/models/NewContactpage.ts new file mode 100644 index 00000000..f8083e87 --- /dev/null +++ b/src/features/api/strapi/models/NewContactpage.ts @@ -0,0 +1,96 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * DOCUMENTATION + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Contact: contact-email@something.io + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import { + AboutpageSeo, + AboutpageSeoFromJSON, + AboutpageSeoFromJSONTyped, + AboutpageSeoToJSON, +} from './'; + +/** + * + * @export + * @interface NewContactpage + */ +export interface NewContactpage { + /** + * + * @type {AboutpageSeo} + * @memberof NewContactpage + */ + seo?: AboutpageSeo; + /** + * + * @type {string} + * @memberof NewContactpage + */ + body?: string; + /** + * + * @type {Date} + * @memberof NewContactpage + */ + publishedAt?: Date; + /** + * + * @type {string} + * @memberof NewContactpage + */ + createdBy?: string; + /** + * + * @type {string} + * @memberof NewContactpage + */ + updatedBy?: string; +} + +export function NewContactpageFromJSON(json: any): NewContactpage { + return NewContactpageFromJSONTyped(json, false); +} + +export function NewContactpageFromJSONTyped(json: any, ignoreDiscriminator: boolean): NewContactpage { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'seo': !exists(json, 'seo') ? undefined : AboutpageSeoFromJSON(json['seo']), + 'body': !exists(json, 'body') ? undefined : json['body'], + 'publishedAt': !exists(json, 'published_at') ? undefined : (new Date(json['published_at'])), + 'createdBy': !exists(json, 'created_by') ? undefined : json['created_by'], + 'updatedBy': !exists(json, 'updated_by') ? undefined : json['updated_by'], + }; +} + +export function NewContactpageToJSON(value?: NewContactpage | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'seo': AboutpageSeoToJSON(value.seo), + 'body': value.body, + 'published_at': value.publishedAt === undefined ? undefined : (value.publishedAt.toISOString()), + 'created_by': value.createdBy, + 'updated_by': value.updatedBy, + }; +} + + diff --git a/src/features/api/strapi/models/index.ts b/src/features/api/strapi/models/index.ts index 94347e77..b51995fe 100644 --- a/src/features/api/strapi/models/index.ts +++ b/src/features/api/strapi/models/index.ts @@ -5,6 +5,7 @@ export * from './AboutpageSeo'; export * from './Article'; export * from './Category'; export * from './Comment'; +export * from './Contactpage'; export * from './Global'; export * from './Homepage'; export * from './HomepageHero'; @@ -14,6 +15,7 @@ export * from './NewArticle'; export * from './NewArticleComment'; export * from './NewCategory'; export * from './NewComment'; +export * from './NewContactpage'; export * from './NewGlobal'; export * from './NewHomepage'; export * from './NewProject'; diff --git a/src/features/contact/api.ts b/src/features/contact/api.ts new file mode 100644 index 00000000..d90c494a --- /dev/null +++ b/src/features/contact/api.ts @@ -0,0 +1,6 @@ +import { apiClient } from '../api/apiClient'; +import { Contactpage } from '../api/strapi/models/Contactpage'; + +export async function getContactPage(): Promise { + return await apiClient.contactPageApi.contactpageGet({}); +} diff --git a/src/features/layout/PageShell/PageShell.tsx b/src/features/layout/PageShell/PageShell.tsx index b50c501b..d29be41f 100644 --- a/src/features/layout/PageShell/PageShell.tsx +++ b/src/features/layout/PageShell/PageShell.tsx @@ -21,7 +21,7 @@ export const PageShell: React.FC = ({ return ( - {title} - Richard Willis + Richard Willis - {title}
diff --git a/src/features/pages/ContactPage/ContactPage.tsx b/src/features/pages/ContactPage/ContactPage.tsx index 16db8483..e1388b6c 100644 --- a/src/features/pages/ContactPage/ContactPage.tsx +++ b/src/features/pages/ContactPage/ContactPage.tsx @@ -6,23 +6,30 @@ import { PageShell } from '../../layout/PageShell/PageShell'; import { Typography } from '../../layout/Typography/Typography'; import STYLES from './ContactPage.module.scss'; +import { MDXRemoteSerializeResult } from 'next-mdx-remote'; +import { AboutpageSeo } from '../../api/strapi'; +import { MarkdownContent } from '../../blog/MarkdownContent/MarkdownContent'; const classes = classNames.bind(STYLES); -export const ContactPage: React.FC = () => { +export type ContactPageProps = { + mdxSource: MDXRemoteSerializeResult>; + seo: AboutpageSeo; +}; + +export const ContactPage: React.FC = ({ seo, mdxSource }) => { return ( - + -

Contact

+ +

{seo.metaTitle}

+ +
  • + className={classes('social-link')}> GitHub
  • @@ -30,8 +37,7 @@ export const ContactPage: React.FC = () => { + className={classes('social-link')}> StackOverflow @@ -39,8 +45,7 @@ export const ContactPage: React.FC = () => { + className={classes('social-link')}> LinkedIn diff --git a/src/features/projects/ProjectsPage/ProjectsPage.tsx b/src/features/projects/ProjectsPage/ProjectsPage.tsx index 7ee3caf0..f7ec4206 100644 --- a/src/features/projects/ProjectsPage/ProjectsPage.tsx +++ b/src/features/projects/ProjectsPage/ProjectsPage.tsx @@ -5,12 +5,13 @@ import { PageShell } from '../../layout/PageShell/PageShell'; import { ProjectsList } from '../ProjectsList/ProjectsList'; import { AboutpageSeo, Project } from '../../api/strapi'; import { MarkdownContent } from '../../blog/MarkdownContent/MarkdownContent'; +import { Typography } from '../../layout/Typography/Typography'; -export interface ProjectsPageProps { +export type ProjectsPageProps = { allProjects: Project[]; mdxSource: MDXRemoteSerializeResult>; seo: AboutpageSeo; -} +}; export const ProjectsPage: React.FC = ({ allProjects, @@ -19,8 +20,10 @@ export const ProjectsPage: React.FC = ({ }) => { return ( -

    {seo.metaTitle}

    - + +

    {seo.metaTitle}

    + +
    ); diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 114778d9..3f00e4bf 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -33,8 +33,7 @@ export default class MyDocument extends Document { + src="https://plausible.docker-box.richardwillis.info/js/plausible.js">
    diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx index 5fa35138..86be0217 100644 --- a/src/pages/contact.tsx +++ b/src/pages/contact.tsx @@ -1 +1,20 @@ +import { GetStaticProps } from 'next'; +import { serialize } from 'next-mdx-remote/serialize'; +import { getSanitisedResponse } from '../features/api/apiClient'; +import { AboutpageSeo } from '../features/api/strapi'; +import { getContactPage } from '../features/contact/api'; +import { ContactPageProps } from '../features/pages/ContactPage/ContactPage'; + export { ContactPage as default } from '../features/pages/ContactPage/ContactPage'; + +export const getStaticProps: GetStaticProps = async () => { + const contactPage = await getContactPage(); + const { body = '', seo } = contactPage; + const mdxSource = await serialize(body); + return { + props: { + mdxSource, + seo: getSanitisedResponse(seo), + }, + }; +}; diff --git a/src/pages/projects.tsx b/src/pages/projects.tsx index 82008b4e..b73b3c29 100644 --- a/src/pages/projects.tsx +++ b/src/pages/projects.tsx @@ -1,13 +1,14 @@ import { GetStaticProps } from 'next'; import { serialize } from 'next-mdx-remote/serialize'; import { getSanitisedResponse } from '../features/api/apiClient'; -import { Aboutpage, AboutpageSeo } from '../features/api/strapi'; +import { AboutpageSeo } from '../features/api/strapi'; export { ProjectsPage as default } from '../features/projects/ProjectsPage/ProjectsPage'; import { getAllProjects, getProjectsPage } from '../features/projects/api'; +import { ProjectsPageProps } from '../features/projects/ProjectsPage/ProjectsPage'; -export const getStaticProps: GetStaticProps = async () => { +export const getStaticProps: GetStaticProps = async () => { const allProjects = await getAllProjects(); const projectsPage = await getProjectsPage(); const { body = '', seo } = projectsPage;