Answer the question
In order to leave comments, you need to log in
How to extract id from url?
For a custom router, you need a function to pull parameters from the url. Works like this:
localhost:3000 - index page
localhost:3000/#items - item page
localhost:3000/#items/10/index - item id 10
Answer the question
In order to leave comments, you need to log in
Good day.
I read your question, but before that I "rummaged through the entire space of the Internet" and unfortunately nothing came of it (((
But ...
When I clearly began to delve into the essence, I realized one thing that the Google console gives an error on the pages of product categories and tags (tags) of the product.
That is, Google sees these pages as a separate product and, accordingly, there is no price, no reviews, in short, nothing from what is needed for the product page.
I installed the Rank Math SEO plugin and in the metadata settings there is under the settings for product categories and product tags, and there is a checkbox "Delete data from snippet (Delete schema markup data from Category (Label))" and everything worked fine.
I'm not a coder, just the owner of an online store, I don't know where and what and how to prescribe. This method helped me and I hope it will help someone else.
If I understand correctly, then you can
var link = 'localhost:3000/#items/10/index';
var arr = link.split('/');
console.log(arr[2]); //10
judging by localhost:3000, so I understand you have ruby? but if not, then anyway ..
in the general backend, pull out the value and insert it into the input in the header of the type template
like this:
And then with the help of js you take the value:
The option is probably clumsy .... but I think it should work)
And if it's pure js, then as the option above. It is necessary to take the value of the address bar and decompose it into an array or take it through regular expressions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question