Me enfrento a un problema de barra inclinada similar a este ¿Cómo eliminar las barras inclinadas en el proyecto Gatsby? . cuando trato de recargar solo por un segundo, está cargando la URL con una barra diagonal como website.com/page1/ y luego regresa a website.com/page1. está sucediendo para los que creé en gatsby-node.js. Intenté eliminar el complemento de barras inclinadas pero no obtuve el resultado
Estaré agradecido por cualquier ayuda. Gracias.
Así es como se ve mi gatsby-node.js
const path = require(`path`) const { slash } = require(`gatsby-core-utils`) exports.createPages = async ({ graphql, actions }) => { const { createPage } = actions // query content for WordPress posts const { data: { allWpLandingPage: { nodes: allLandingPages }, allWpPost: { nodes: allPosts }, }, } = await graphql(` query { allWpLandingPage { nodes { id, slug, landing_page{ baseFolder } } } allWpPost { nodes { categories { nodes { slug } } blogPostInfo { adressForUrl img { mediaItemUrl altText } } author{ node{ name } } content id title } } } `) const postTemplate = path.resolve(`./src/pages/landing.js`); allLandingPages.forEach(post => { let title = post.landing_page.baseFolder.toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"").split(' ').join('-'); post.uri = title + '/' + post.slug; createPage({ // will be the url for the page //path: post.slug, path: '/' + post.uri , // specify the component template of your choice component: slash(postTemplate), // In the ^template's GraphQL query, 'id' will be available // as a GraphQL variable to query for this post's data. context: { id: post.id, }, }) }) let filteredPosts = allPosts.filter((item) => { for (let i = 0; i < item.categories.nodes.length; i++){ if (item.categories.nodes[i].slug === "blog-posts"){ return item; } } }); const blogPostTemplate = path.resolve(`./src/pages/article-page.js`); filteredPosts.forEach(post => { createPage({ path: 'blog/' + post.blogPostInfo.adressForUrl, component: slash(blogPostTemplate), context: { id: post.id, }, }) }) }¿Ha intentado eliminar la barra inclinada final en la creación de slug ?
createPage({ path: '/' + post.uri.replace(/\/$/, ""), component: slash(postTemplate), context: { id: post.id, }, }) La expresión regular replace(/\/$/, "") debería funcionar