From 8a32bfb8f12d6da6213507bd354f5cd9786170f5 Mon Sep 17 00:00:00 2001 From: Conventional Changelog Action Date: Fri, 11 Feb 2022 06:56:43 +0000 Subject: [PATCH 1/5] chore(release): v0.2.0 --- CHANGELOG.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6766e0..d4adfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ -# 0.1.0 (2022-02-10) +# 0.2.0 (2022-02-11) ### Features -* add nextjs snippet ([8bd2027](https://github.com/avneesh0612/React-Next.js-snippets/commit/8bd2027d3a8fc5d30ea926319f263f029463139d)) -* added next js typescript component ([7da5468](https://github.com/avneesh0612/React-Next.js-snippets/commit/7da54689a5ab29ac27d9cf7c5dbf48e3e7f80ed8)) +* add nextjs snippet ([8bd2027](https://github.com/crebro/React-Next.js-snippets/commit/8bd2027d3a8fc5d30ea926319f263f029463139d)) +* added next js typescript component ([7da5468](https://github.com/crebro/React-Next.js-snippets/commit/7da54689a5ab29ac27d9cf7c5dbf48e3e7f80ed8)) diff --git a/package.json b/package.json index f38ae54..7ab4294 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nextreactsnippets", "displayName": "Next.js and React Snippets", "description": "This is an extension for Next.js and React Snippets with ts support as well!", - "version": "0.1.0", + "version": "0.2.0", "engines": { "vscode": "^1.64.0" }, From 230a8bdaafe0094793beb9aac715736c2e6f1dc6 Mon Sep 17 00:00:00 2001 From: crebro Date: Fri, 11 Feb 2022 13:15:49 +0545 Subject: [PATCH 2/5] feat: add snippets for getInitialProps and (fix) use TM_FILENAME_BASE instead of TM_FILENAME --- snippets/next-typescript.code-snippets | 16 ++++++++++++++-- snippets/react-javascript.code-snippets | 4 ++-- snippets/react-typescript.code-snippets | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/snippets/next-typescript.code-snippets b/snippets/next-typescript.code-snippets index e175312..2ba6605 100644 --- a/snippets/next-typescript.code-snippets +++ b/snippets/next-typescript.code-snippets @@ -28,17 +28,29 @@ "body": [ "import type { NextPage } from \"next\";", "", - "const ${1:${TM_FILENAME}}: NextPage = () => {", + "const ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}: NextPage = () => {", " return (", " <>", " ", " )", "}", "", - "export default ${1:${TM_FILENAME}}" + "export default ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}" ], "description": "NextPage component with NextPage type" }, + "nextgip": { + "prefix": "nextgip", + "body": [ + "${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}.getInitialProps = async context => {", + " return {", + " ", + " };", + "};", + "" + ], + "description": "Get Initial Props in Next.js" + }, "nct": { "prefix": "nextct", "body": [ diff --git a/snippets/react-javascript.code-snippets b/snippets/react-javascript.code-snippets index facad22..16135ea 100644 --- a/snippets/react-javascript.code-snippets +++ b/snippets/react-javascript.code-snippets @@ -2,11 +2,11 @@ "rafce": { "prefix": "rafce", "body": [ - "const ${1:${TM_FILENAME}}= () => {", + "const ${1:${TM_FILENAME_BASE}}= () => {", " return
;", "};", "", - "export default ${1:${TM_FILENAME}};", + "export default ${1:${TM_FILENAME_BASE}};", "" ], "description": "React Functional Component" diff --git a/snippets/react-typescript.code-snippets b/snippets/react-typescript.code-snippets index d21816c..4ec3b9b 100644 --- a/snippets/react-typescript.code-snippets +++ b/snippets/react-typescript.code-snippets @@ -6,10 +6,10 @@ "", "interface Props {}", "", - "const ${1:${TM_FILENAME}}: FC = () => {", + "const ${1:${TM_FILENAME_BASE}}: FC = () => {", " return
;", "};", - "export default ${1:${TM_FILENAME}};" + "export default ${1:${TM_FILENAME_BASE}};" ], "description": "React Functional Component with Types" } From 665e9566da2896133d8e9f163474323c47239fc7 Mon Sep 17 00:00:00 2001 From: crebro Date: Fri, 11 Feb 2022 13:28:48 +0545 Subject: [PATCH 3/5] docs: update documentation (README.md) for next.js getInitialProps --- README.md | 60 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index a8d8696..7fdd226 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ NextJS and React Snippets with TypeScript support as well!🚀 ```jsx const Component = () => { - return
; - }; - export default Component; + return
+ } + export default Component ``` ### TypeScript @@ -28,12 +28,12 @@ NextJS and React Snippets with TypeScript support as well!🚀 2. `rafect` (React Functional Component with Types) ```tsx - import { FC } from "react"; + import { FC } from 'react' interface Props {} const Component: FC = () => { - return
; - }; - export default Component; + return
+ } + export default Component ``` ## NextJS @@ -46,8 +46,8 @@ NextJS and React Snippets with TypeScript support as well!🚀 export const getServerSideProps = async (context) => { return { props: {}, - }; - }; + } + } ``` 2. `nextssg` (Get Static Props Next.js) @@ -56,8 +56,8 @@ NextJS and React Snippets with TypeScript support as well!🚀 export const getStaticProps = async (context) => { return { props: {}, - }; - }; + } + } ``` ### TypeScript @@ -66,37 +66,45 @@ NextJS and React Snippets with TypeScript support as well!🚀 ```tsx export const getServerSideProps: GetServerSideProps = async (context) => { - return { props: {} }; - }; + return { props: {} } + } ``` 2. `nextssgt` (Get Static Props Next.js) ```tsx export const getStaticProps: getStaticProps = async (context) => { - return { props: {} }; - }; + return { props: {} } + } ``` -3. `taytay` (NextPage component with NextPage type) +3. `nextgip` (Get Initial Props in Next.js) ```tsx - import type { NextPage } from "next"; + Page.getInitialProps = async (context) => { + return { props: {} } + } + ``` + +3) `taytay` (NextPage component with NextPage type) + + ```tsx + import type { NextPage } from 'next' const Page: NextPage = () => { - return <>; - }; - export default Page; + return <> + } + export default Page ``` -4. `nextct` (Next JS Component with NextComponentType and Props) +4) `nextct` (Next JS Component with NextComponentType and Props) ```tsx - import type { NextComponentType, NextPageContext } from "next"; + import type { NextComponentType, NextPageContext } from 'next' interface Props {} const Component: NextComponentType = ( - props: Props + props: Props, ) => { - return
; - }; - export default Component; + return
+ } + export default Component ``` From decd24b56dd3302a29b314f3e985e21cc372a3b7 Mon Sep 17 00:00:00 2001 From: Avneesh Agarwal Date: Fri, 11 Feb 2022 13:23:14 +0530 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4adfa3..83c5e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,7 @@ -# 0.2.0 (2022-02-11) +# 0.1.0 (2022-02-11) ### Features -* add nextjs snippet ([8bd2027](https://github.com/crebro/React-Next.js-snippets/commit/8bd2027d3a8fc5d30ea926319f263f029463139d)) -* added next js typescript component ([7da5468](https://github.com/crebro/React-Next.js-snippets/commit/7da54689a5ab29ac27d9cf7c5dbf48e3e7f80ed8)) - - - +* add nextjs snippet ([8bd2027](https://github.com/avneesh0612/React-Next.js-snippets/commit/8bd2027d3a8fc5d30ea926319f263f029463139d)) +* added next js typescript component ([7da5468](https://github.com/avneesh0612/React-Next.js-snippets/commit/7da54689a5ab29ac27d9cf7c5dbf48e3e7f80ed8)) From 4ac19fe22dd6415224abfc53d27f78c0bec459d8 Mon Sep 17 00:00:00 2001 From: Avneesh Agarwal Date: Fri, 11 Feb 2022 13:24:03 +0530 Subject: [PATCH 5/5] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ab4294..7ce70d6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nextreactsnippets", "displayName": "Next.js and React Snippets", "description": "This is an extension for Next.js and React Snippets with ts support as well!", - "version": "0.2.0", + "version": "0.1.0", "engines": { "vscode": "^1.64.0" }, @@ -40,4 +40,4 @@ "devDependencies": { "husky": "^7.0.4" } -} \ No newline at end of file +}