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

Nuxt 2 Bridge #281

Open
thisismydesign opened this issue Jan 26, 2023 · 0 comments
Open

Nuxt 2 Bridge #281

thisismydesign opened this issue Jan 26, 2023 · 0 comments

Comments

@thisismydesign
Copy link

thisismydesign commented Jan 26, 2023

How to make this package work on Nuxt 2 Bridge

There are (at least) 2 things that don't seem to work with Nuxt 2 Bridge:

Working solution

Use patch-package or a fork to rename the hook. You can use my working fork in package.json: "@nuxtjs/sitemap": "thisismydesign/sitemap-module#cd4dc22293b9b67e8ebb5b3c49840e67c108e312"

Use a workaround to copy sitemaps into the static folder rather than relying on a middleware to serve them:

nuxt.config.ts

  hooks: {
    sitemap: {
      generate: {
        done(nuxtInstance) {
          fs.copyFileSync(
            `${nuxtInstance.options.generate.dir}/sitemap.xml`,
            `static/sitemap.xml`
          )
        },
      },
    },
  },

The sitemap is now available at /sitemap.xml

As this is a static file it will only update upon deploy. Keep this in mind for dynamic routes.

How to release this with the package

The hook used and the middleware could be conditional on the dependencies. That would fully support Nuxt 2 Bridge and possibly Nuxt 3 as well.

@thisismydesign thisismydesign changed the title Nuxt Bridge support Nuxt 2 Bridge Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant