//[pid].tsx
import { GetStaticPaths, GetStaticProps } from 'next';
import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/router';
import axios from '../../utils/axiosBase';
const getPost = (pid) => {
return axios.get('/get-post', { params: { pid } });
};
const Post = ({ post }) => {
const { data } = useQuery(['get-post'], getPost, { initialData: post });
return <p>h</p>;
};
export const getStaticProps: GetStaticProps = async (context) => {
const post = await getPost(context.params.pid);
return {
props: { post: post.data }
};
};
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [],
fallback: 'blocking'
};
};
export default Post;
//[pid].tsx
import { GetStaticPaths, GetStaticProps } from 'next';
import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/router';
import axios from '../../utils/axiosBase';
const getPost = (pid) => {
return axios.get('/get-post', { params: { pid } });
};
const Post = ({ post }) => {
const { data } = useQuery(['get-post'], getPost, { initialData: post });
return <p>h</p>;
};
export const getStaticProps: GetStaticProps = async (context) => {
const post = await getPost(context.params.pid);
return {
props: { post: post.data }
};
};
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [],
fallback: 'blocking'
};
};
export default Post;