Comments (4)
@talpx0 That's my version of doing it. All the posts will be rendered during building time. Checkout my website https://tonywang.io if you're interested.
export const generateStaticParams = async () => {
const allBlogs = getBlogPosts();
const paths = allBlogs.map((post)=> ({slug: post.slug}))
return paths
}
from leerob.io.
First, "https://.../posts" would not be a valid URL. But the main server is indeed that the data is read from local sources. Each page load will also update the view counter
from leerob.io.
First, "https://.../posts" would not be a valid URL. But the main server is indeed that the data is read from local sources. Each page load will also update the view counter
https://nextjs.org/docs/app/api-reference/functions/generate-static-params
- So ,my question is like,The generateStaticParams function can be used in combination with dynamic route segments to statically generate routes at build time instead of on-demand at request time. But since it is read from local resources,it will automatically get injected at build time?
from leerob.io.
@talpx0 You're right, you can retrieve the slug and set it with generateStaticParams
, which will generate the routes at the build time which I'd recommend.
leerob.io/app/blog/[slug]/page.tsx
Lines 10 to 13 in e9357c5
@PieterDePauw The URL can be valid in many ways for example using the route.ts
, GitHub API, etc.
from leerob.io.
Related Issues (20)
- Template contains hard-coded urls to leerob.io HOT 1
- Error: Table 'leeroy.views' doesn't exist when trying to go to the blog page HOT 2
- failed with YAMLParseError HOT 1
- Question HOT 1
- VercelPostgresError: VercelPostgresError - 'invalid_connection_string': HOT 1
- doc: include ```license``` file HOT 1
- Consider adding a custom ```not-found```
- Geist does not work with the canary version ? HOT 1
- Blog publishedAt date from mdx frontmatter appears one day behind on the site HOT 2
- OG image appears pixelated
- Creating a public template HOT 2
- Blog timestamp shows wrong time ago. HOT 1
- Deployment to vercel is failing. HOT 3
- Edge Function "og" size is too big. HOT 5
- Safari Image Layout Shift HOT 4
- Error: Postgres connection Can't resolve 'perf_hooks' HOT 2
- Add Search feature on top of blog tab HOT 1
- Unhandled Runtime Error HOT 3
- deployed but seeing base template HOT 2
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 leerob.io.