Git Product home page Git Product logo

Comments (5)

tirthbodawala avatar tirthbodawala commented on July 16, 2024 1

@taqimustafa updateSeo updates meta tag in development mode, but when you build your application, the same function returns updated metadata in source file thus giving expected output in production mode.

from react-pwa.

tirthbodawala avatar tirthbodawala commented on July 16, 2024

Yes @bytewiz. We have taken care of that. Sorry, the docs are not yet available but let me share a code snippet here.

const routes = [
  {
    path: "/blog/:id",
    layout: DefaultLayout,
    component: BlogPost,
    preLoadData: async ({match, api, updateSeo}) => {
      const { params } = match;
      const postData = await api.fetch(`https://<your-api-url>/posts/${params.id}`, { swcache: 20000 });
      updateSeo({
        title: postData.title,
        description: postData.desc,
      });
      return postData;
    },
  }
];

Thus you can take care of SEO for dynamic pages.

from react-pwa.

bytewiz avatar bytewiz commented on July 16, 2024

@tirthbodawala awesome and thank you very much for the fast response! πŸ‘

from react-pwa.

taqimustafa avatar taqimustafa commented on July 16, 2024

@tirthbodawala the updateSEO part works similar to react-helmet ? or does it actually update the meta tags in page source ?

Right now i tried this code, but it's only updating meta tags in inspect view. I don't think FB crawler or other social media crawlers will be able to get the dynamic meta tags.

https://developers.facebook.com/tools/debug/

from react-pwa.

naga-RajanR avatar naga-RajanR commented on July 16, 2024

@tirthbodawala I tried this updateSEO code but it doesn't throw any error or reflect any changes in meta tags, so can you please help me with the issue in the following code
const routes = [
{
path: '/',
exact: true,
component: () => import('../components/GuestUserPage/index'),
preLoadData: async ({ match, api, updateSeo }) => {
console.log('preloading')
const { params } = match;
const postData = await api.fetch(https://jsonplaceholder.typicode.com/todos/1, { swcache: 20000 });
updateSeo({
title: postData.title,
description: postData.title,
});
return postData;
}]

from react-pwa.

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.