Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A page re-rendering and page deletion composable #27058

Open
3 of 4 tasks
CHIBX opened this issue May 3, 2024 · 2 comments
Open
3 of 4 tasks

A page re-rendering and page deletion composable #27058

CHIBX opened this issue May 3, 2024 · 2 comments

Comments

@CHIBX
Copy link

CHIBX commented May 3, 2024

Describe the feature

This request is for the implementation of a renderPage() method capable of calling the internal prerender process of Nuxt to render, not just normal pages, but those with dynamic slugs.
I believe this feature would prove significant for blogs, and various static sites to control the re-rendering of specific pages upon update to their respective data.

export default defineEventHandler(async (event)=>{
  await renderPage('/posts/24', { query1:  'mostLiked' });
});

The previous way of adding prerenderable slugs below results in the the need to rebuild to get fresh new routes/slugs:

import { ofetch } from 'ofetch';

const getPlanetsRoutes = async () => {
    const response = await ofetch("https://api.nuxtjs.dev/planets");
    return response.map((planet) => `/planets/${planet.slug}`);
}

export default defineNuxtConfig({
    hooks: {
        async 'nitro:config'(nitroConfig) {
            const planetsRoutes = await getPlanetsRoutes();
            nitroConfig.prerender.routes.push(...planetsRoutes);
        }
    }
});

This feature request prevents the need for unnecessary rebuild and allows re-rendering to occur server-side. This will improve flexibility and ease as anyone could cache a page based on data/[slug title] gotten from a database.
Developers will be able to delete pages that are no longer needed (maybe after deletion of data from a store) using removePage(route).

The feature would be added only for users with the prerender feature enabled on at least one route, so as to avoid rendering conflicts with a full SSR app rendering mechanism

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@kc-fantasy
Copy link

Yes, I need that feature, too。dynamically update some static prerender pages

@danielroe
Copy link
Member

cc: @pi0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants