Created
          October 10, 2025 22:06 
        
      - 
      
- 
        Save james2doyle/62da26fdb006fde0faf08b31d02926b1 to your computer and use it in GitHub Desktop. 
    Generate nested URLs using Groq functions in Sanity
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // since the argument variable can only be referenced once, we need this function repeated | |
| fn ex::p($p) = $p->{"c":url.current}; | |
| fn ex::pp($p) = $p->{"c": ex::p(parentPage).c}; | |
| fn ex::ppp($p) = $p->{"c": ex::pp(parentPage).c}; | |
| // will output `level-4/level-3/level-2/level-1` | |
| // usage: { "href": ex::slug(@) } | |
| fn ex::slug($d) = $d{"slug":array::join( | |
| array::compact([ | |
| ex::ppp(parentPage).c, | |
| ex::pp(parentPage).c, | |
| ex::p(parentPage).c, | |
| url.current | |
| ]), | |
| '/' | |
| )}; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment