D
D
DefProger2021-02-13 04:29:14
React
DefProger, 2021-02-13 04:29:14

How to find the path to a file using graphql?

I'm making a site on react.js in the menu there are 5 links to 5 pages, and I need to make sure that the active one is highlighted, in order to determine the active page, I want to get the path to the active page from graphql.
Tried to hack something in graphql:
Query{
sitePage {
path
}
}

Obviously doesn't work and I'm sure it's far from correct

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Lanets, 2021-02-13
@Fi1osof

But why do it through a graph? Usually sites use the react-router-dom type, and with its help they determine which page is now and whether the link is active or not.
It specifically has NavLink. It becomes active itself when it matches. It remains only to specify the class of the active link. https://reactrouter.com/web/api/NavLink

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question