Coder Social home page Coder Social logo

Comments (8)

TriPSs avatar TriPSs commented on May 8, 2024 1

Yes that seems to work 🎉

My file now:

export default {
  /**
   * An asynchronous register function that runs before
   * your application is initialized.
   *
   * This gives you an opportunity to extend code.
   */
  register(/*{ strapi }*/) {},

  /**
   * An asynchronous bootstrap function that runs before
   * your application gets started.
   *
   * This gives you an opportunity to set up your data model,
   * run jobs, or perform some special logic.
   */
  async bootstrap({ strapi }) {
    await strapi.plugin('sitemap').service('core').createSitemap();
  },
};

from strapi-plugin-sitemap.

boazpoolman avatar boazpoolman commented on May 8, 2024

Hmmm, interesting feature request.
You could actually do this yourself aswell.

Just put this code in your bootstrap function:

strapi.plugin('sitemap').service('core').createSitemap();

from strapi-plugin-sitemap.

TriPSs avatar TriPSs commented on May 8, 2024

Aah, I did not know that, created an API now that generates it if the file does not exist.

Is there any docs available about adding to bootstrap? I searched for it but could not find anything, that's why I created the API.

from strapi-plugin-sitemap.

boazpoolman avatar boazpoolman commented on May 8, 2024

EDIT: OK apparently there is no real documentation about this, but you can see here that the bootstrap function can be called from the src/admin/app.js file: https://docs.strapi.io/developer-docs/latest/development/admin-customization.html#locales

from strapi-plugin-sitemap.

TriPSs avatar TriPSs commented on May 8, 2024

Thanks! Then this ticket can be closed as this would do exactly what I need.

from strapi-plugin-sitemap.

boazpoolman avatar boazpoolman commented on May 8, 2024

Great :)
Do let me know if it works out for you.
If not I might add this as a feature

from strapi-plugin-sitemap.

TriPSs avatar TriPSs commented on May 8, 2024

Currently have this:

export default {
  config: {
    locales: []
  },
  async bootstrap({ strapi }) {
    await strapi.plugin('sitemap').service('core').createSitemap()
  }
}

But it does not work, I think this is because it's ran on the client side when going to the admin panel.

from strapi-plugin-sitemap.

boazpoolman avatar boazpoolman commented on May 8, 2024

You are right. Pardon me. My bad. There is documentation about the server bootstrap phase.
Right here: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/functions.html#bootstrap

from strapi-plugin-sitemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.