fixed built errors in ssg mode

This commit is contained in:
Ren Amamiya 2023-02-23 07:39:18 +07:00
parent 247f28ae75
commit 8a79938391
5 changed files with 35 additions and 43 deletions

View File

@ -17,14 +17,8 @@ const DynamicContent = dynamic(() => import('@components/note/content'), {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const Single = memo(function Single({ event }: { event: any }) {
const openThread = () => {
console.log('ok');
};
return (
<div
onClick={() => openThread()}
className="flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-4 px-6 hover:bg-zinc-800">
<div className="flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-4 px-6 hover:bg-zinc-800">
<div className="flex flex-col">
<User pubkey={event.pubkey} time={event.created_at} />
<div className="-mt-4 pl-[60px]">

View File

@ -1,24 +0,0 @@
import BaseLayout from '@layouts/baseLayout';
import UserLayout from '@layouts/userLayout';
import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal } from 'react';
export default function Page() {
return <></>;
}
Page.getLayout = function getLayout(
page:
| string
| number
| boolean
| ReactElement<unknown, string | JSXElementConstructor<unknown>>
| ReactFragment
| ReactPortal
) {
return (
<BaseLayout>
<UserLayout>{page}</UserLayout>
</BaseLayout>
);
};

View File

@ -3,6 +3,7 @@ import BaseLayout from '@layouts/baseLayout';
import OnboardingLayout from '@layouts/onboardingLayout';
import { motion } from 'framer-motion';
import { GetStaticPaths } from 'next';
import { useRouter } from 'next/router';
import { useNostrEvents } from 'nostr-react';
import {
@ -15,12 +16,11 @@ import {
} from 'react';
import Database from 'tauri-plugin-sql-api';
export default function Page() {
export default function Page({ pubkey }: { pubkey: string }) {
const [follows, setFollows] = useState([null]);
const [loading, setLoading] = useState(false);
const router = useRouter();
const { pubkey }: any = router.query;
const { onEvent } = useNostrEvents({
filter: {
@ -108,6 +108,20 @@ export default function Page() {
);
}
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [],
fallback: 'blocking',
};
};
export async function getStaticProps(context) {
const pubkey = context.params.pubkey;
return {
props: { pubkey },
};
}
Page.getLayout = function getLayout(
page:
| string

View File

@ -46,10 +46,7 @@ export default function Page() {
const pubKey = getPublicKey(privKey);
if (pubKey) {
router.push({
pathname: '/onboarding/fetch-profile',
query: { privkey: privKey },
});
router.push(`/onboarding/profile/${privKey}`);
}
} catch (error) {
setError('key', {

View File

@ -3,6 +3,7 @@ import BaseLayout from '@layouts/baseLayout';
import OnboardingLayout from '@layouts/onboardingLayout';
import { motion } from 'framer-motion';
import { GetStaticPaths } from 'next';
import { useRouter } from 'next/router';
import { useNostrEvents } from 'nostr-react';
import { getPublicKey, nip19 } from 'nostr-tools';
@ -16,12 +17,11 @@ import {
} from 'react';
import Database from 'tauri-plugin-sql-api';
export default function Page() {
export default function Page({ privkey }: { privkey: string }) {
const [account, setAccount] = useState(null);
const [loading, setLoading] = useState(false);
const router = useRouter();
const { privkey }: any = router.query;
const pubkey = getPublicKey(privkey);
const npub = nip19.npubEncode(pubkey);
@ -61,10 +61,7 @@ export default function Page() {
.then(() => {
setTimeout(() => {
setLoading(false);
router.push({
pathname: '/onboarding/fetch-follows',
query: { pubkey: pubkey },
});
router.push(`/onboarding/follows/${pubkey}`);
}, 1500);
})
.catch(console.error);
@ -116,6 +113,20 @@ export default function Page() {
);
}
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [],
fallback: 'blocking',
};
};
export async function getStaticProps(context) {
const privkey = context.params.privkey;
return {
props: { privkey },
};
}
Page.getLayout = function getLayout(
page:
| string