From 0144bfc9cc6c616a00a8171f3950a75ec948427e Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 10:27:27 -0700 Subject: base next refactor --- frontend/src/pages/raw/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 frontend/src/pages/raw/index.js (limited to 'frontend/src/pages/raw') diff --git a/frontend/src/pages/raw/index.js b/frontend/src/pages/raw/index.js new file mode 100644 index 0000000..86db3d4 --- /dev/null +++ b/frontend/src/pages/raw/index.js @@ -0,0 +1,14 @@ +import React from 'react'; +import useFetchPaste from "../../http/useFetchPaste"; +import { useRouter } from 'next/router' + + +export default (req, res) => { + const router = useRouter() + const { hash } = router.query + const { err, result } = useFetchPaste(hash) + res.statusCode = 200 + res.json({ + text: 'Hello World! This is the Next.js starter kit :D', + }) +} \ No newline at end of file -- cgit v1.2.3 From 77c061bc0b8aecce7311ce820b3401c95797a589 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 11:40:44 -0700 Subject: working raw paste fetch --- frontend/src/pages/raw/[hash].js | 24 ++++++++++++++++++++++++ frontend/src/pages/raw/index.js | 14 -------------- 2 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 frontend/src/pages/raw/[hash].js delete mode 100644 frontend/src/pages/raw/index.js (limited to 'frontend/src/pages/raw') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js new file mode 100644 index 0000000..d0a66a7 --- /dev/null +++ b/frontend/src/pages/raw/[hash].js @@ -0,0 +1,24 @@ +import React from 'react'; +import resolvePaste from "../../http/useFetchPaste"; +import {CodeLike} from "../../components/Common/mixins"; +import styled from 'styled-components' + +const RawText = styled.pre` + ${CodeLike} + padding: 0 1em; +` + +export async function getServerSideProps(ctx) { + const data = await resolvePaste(ctx.params.hash) + + // Pass data to the page via props + return { props: { ...data } } +} + +const Raw = ({error, data}) => { + return + {data?.content || error} + +} + +export default Raw \ No newline at end of file diff --git a/frontend/src/pages/raw/index.js b/frontend/src/pages/raw/index.js deleted file mode 100644 index 86db3d4..0000000 --- a/frontend/src/pages/raw/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import useFetchPaste from "../../http/useFetchPaste"; -import { useRouter } from 'next/router' - - -export default (req, res) => { - const router = useRouter() - const { hash } = router.query - const { err, result } = useFetchPaste(hash) - res.statusCode = 200 - res.json({ - text: 'Hello World! This is the Next.js starter kit :D', - }) -} \ No newline at end of file -- cgit v1.2.3 From 12c995b6bd501be73b60e3bae6c46c59cebef6c2 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 12:30:02 -0700 Subject: base resolve paste and fetch paste refactor --- frontend/src/pages/raw/[hash].js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/src/pages/raw') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index d0a66a7..a100b4b 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -1,5 +1,5 @@ import React from 'react'; -import resolvePaste from "../../http/useFetchPaste"; +import resolvePaste from "../../http/resolvePaste"; import {CodeLike} from "../../components/Common/mixins"; import styled from 'styled-components' -- cgit v1.2.3 From d58c7a3ad5dc83a08e040a855f158f8c6c09e154 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 13:50:20 -0700 Subject: password resolution, dynamic head --- frontend/src/pages/raw/[hash].js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'frontend/src/pages/raw') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index a100b4b..3374eea 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -2,6 +2,7 @@ import React from 'react'; import resolvePaste from "../../http/resolvePaste"; import {CodeLike} from "../../components/Common/mixins"; import styled from 'styled-components' +import NextHead from "../../components/NextHead"; const RawText = styled.pre` ${CodeLike} @@ -10,15 +11,17 @@ const RawText = styled.pre` export async function getServerSideProps(ctx) { const data = await resolvePaste(ctx.params.hash) - - // Pass data to the page via props + console.log(data) return { props: { ...data } } } const Raw = ({error, data}) => { - return - {data?.content || error} - + return <> + {!error && } + + {data?.content || error} + + } export default Raw \ No newline at end of file -- cgit v1.2.3 From dc3f74c642be4dab8ce5507a444ba93371527e78 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 14:55:54 -0700 Subject: fix broken multiline --- frontend/src/pages/raw/[hash].js | 1 - 1 file changed, 1 deletion(-) (limited to 'frontend/src/pages/raw') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index 3374eea..9edde36 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -11,7 +11,6 @@ const RawText = styled.pre` export async function getServerSideProps(ctx) { const data = await resolvePaste(ctx.params.hash) - console.log(data) return { props: { ...data } } } -- cgit v1.2.3