Comments (5)
Closing as it turns out this was an issue on my end.
Missed this section of the guide.
Adding the following to /src/app/blog/[slug]/page.tsx
fixed the issue.
export async function generateStaticParams() {
const posts = getDocumentSlugs('posts')
return posts.map(slug => ({ slug }))
}
from outstatic.
Set revalidate to false.
And add const dynamic = 'force-static'.
Let me know if this works
from outstatic.
Hey @mschinis - thanks for the follow up and I'm glad you figured it out! Let me know if you face any other issues.
from outstatic.
I'm having similar issue, below is the error when deployed to Vercel:
[Error: ENOENT: no such file or directory, open '/var/task/outstatic/content/metadata.json'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/var/task/outstatic/content/metadata.json',
digest: '2192603207'
}
My /src/app/blog/[slug]/page.tsx
import CustomReactMarkdown, {
getTableOfContents,
} from "@/components/CustomReactMarkdown";
import { getDocumentBySlug, getDocumentSlugs, load } from "outstatic/server";
import Image from "next/image";
import { format, parseISO } from "date-fns";
import { TracingBeam } from "@/components/ui/tracing-beam";
import { Metadata } from "next";
import { absoluteUrl } from "@/lib/utils";
import { notFound } from "next/navigation";
interface Params {
params: {
slug: string;
};
}
export const revalidate = 60;
export async function generateStaticParams() {
const posts = getDocumentSlugs("posts");
return posts.map((slug) => ({ slug }));
}
// export async function generateMetadata({
// params: { slug },
// }: any): Promise<Metadata> {
// const post = await getData(slug);
// if (!post) {
// return {};
// }
// return {
// title: post.title,
// description: post.description,
// openGraph: {
// title: post.title,
// description: post.description,
// type: "article",
// url: absoluteUrl(`/blog/${post.slug}`),
// images: [
// {
// url: absoluteUrl(
// post?.coverImage || "/images/post_placeholder_image.avif"
// ),
// width: 1200,
// height: 630,
// alt: post.title,
// },
// ],
// },
// twitter: {
// card: "summary_large_image",
// title: post.title,
// description: post.description,
// images: absoluteUrl(
// post?.coverImage || "/images/post_placeholder_image.avif"
// ),
// },
// };
// }
export default async function Post({ params: { slug } }: Params) {
const post = await getData(slug);
// const toc = getTableOfContents(post.content);
if (!post) return <></>;
return (
<article className="container items-start">
<TracingBeam>
<div className="py-8 text-xl lg:text-5xl font-black">{post.title}</div>
<Date dateString={post.publishedAt} />
<Description description={post.description} />
<PostCoverImage imageUrl={post.coverImage} />
<CustomReactMarkdown markdown={post.content} />
</TracingBeam>
</article>
);
// return (
// <div className="flex-wrap xl:flex mx-auto place-content-center">
// <TableOfContents toc={toc} />
// <article className="grow container place-content-center items-center">
// <div className="py-8 text-xl lg:text-5xl font-black">{post.title}</div>
// <CustomReactMarkdown markdown={post.content} />
// </article>
// </div>
// );
}
async function getData(slug: string): Promise<any> {
const db = await load();
const post = await db
.find({
collection: "posts",
slug: slug,
})
.project([
"title",
"description",
"publishedAt",
"slug",
"author",
"content",
"coverImage",
"category",
"tags",
"featured",
])
.first();
if (!post) {
notFound();
}
return {
props: {
post: {
...post,
},
},
};
}
function PostCoverImage({ imageUrl }: { imageUrl?: string }) {
if (!imageUrl || imageUrl === "") {
return <></>;
}
return (
<div className="relative h-[20rem] my-4">
<Image
src={imageUrl}
alt="Cover Image"
style={{ objectFit: "cover" }}
fill
sizes="(max-width: 768px) 100vw, (max-width: 1024px) 50vw, (max-width: 1280px) 33vw, 33vw"
className="rounded-lg"
/>
</div>
);
}
function Date({ dateString }: { dateString: string }) {
if (!dateString) return <></>;
const date = parseISO(dateString);
const formattedDate = format(date, "MMMM d, yyyy");
return <div className="text-sm opacity-50">{formattedDate}</div>;
}
function Description({ description }: { description: string | undefined }) {
if (!description) return <></>;
return <div className="text-lg opacity-80">{description}</div>;
}
It seems like the page is there after initial deployment, but after revalidate
it's gone.
from outstatic.
Set revalidate to false. And add const dynamic = 'force-static'.
Let me know if this works
Thank you very much! It works! @avitorio
from outstatic.
Related Issues (20)
- getDocuments errors with msg.startsWith is not a function when collection doesn't exist HOT 1
- 'isMacOS' is not exported from '@tiptap/core' HOT 6
- Creating a new collection doesn't creates something on the website HOT 3
- Code highlight doesn't works on the deployed blogs HOT 1
- Cover Image upload does not work when using Safari as the browser. HOT 2
- Can't create any blogs if the title is in another language HOT 5
- Custom fields as columns in collection table HOT 3
- Image is not show HOT 3
- Trouble updating to 1.0.0 - Unsupported URL Type "link:": link:@tiptap/pm/view HOT 1
- Save button not working after upgrade to v1 HOT 10
- Required Author name field not prompting when clicking Save HOT 7
- Dashboard doesn't show default demo collections HOT 11
- Moblie version doest not allow editing HOT 2
- Add an environment variable that reflects next.config.js basePath HOT 1
- Add lang="en" to <html> on new layout files
- Bug: Cover Image HOT 6
- getDocumentBySlug returns null values when draft
- trailingSlash option HOT 1
- Deploy via SST and Outstatic leads to error. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from outstatic.