Top cowboys territory selector fix (#1972)
* fix territory selector when in top/cowboys * redirect /~sub/top/cowboys to /top/cowboys * check if pathname ends with /top/cowboys Co-authored-by: ekzyis <ek@stacker.news> * fix territory selector in top/stackers and top/territories * better routing logic --------- Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
		
							parent
							
								
									fc6cbba40c
								
							
						
					
					
						commit
						9905e6eafe
					
				@ -94,8 +94,19 @@ export default function SubSelect ({ prependSubs, sub, onChange, size, appendSub
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          // we're currently on the home sub
 | 
			
		||||
          // are we in a sub aware route?
 | 
			
		||||
          if (router.pathname.startsWith('/~')) {
 | 
			
		||||
          // if in /top/cowboys, /top/territories, or /top/stackers
 | 
			
		||||
          // and a territory is selected, go to /~sub/top/posts/day
 | 
			
		||||
          if (router.pathname.startsWith('/~/top/cowboys')) {
 | 
			
		||||
            router.push(sub ? `/~${sub}/top/posts/day` : '/top/cowboys')
 | 
			
		||||
            return
 | 
			
		||||
          } else if (router.pathname.startsWith('/~/top/stackers')) {
 | 
			
		||||
            router.push(sub ? `/~${sub}/top/posts/day` : 'top/stackers/day')
 | 
			
		||||
            return
 | 
			
		||||
          } else if (router.pathname.startsWith('/~/top/territories')) {
 | 
			
		||||
            router.push(sub ? `/~${sub}/top/posts/day` : '/top/territories/day')
 | 
			
		||||
            return
 | 
			
		||||
          } else if (router.pathname.startsWith('/~')) {
 | 
			
		||||
            // are we in a sub aware route?
 | 
			
		||||
            // if we are, go to the same path but in the sub
 | 
			
		||||
            asPath = `/~${sub}` + router.asPath
 | 
			
		||||
          } else {
 | 
			
		||||
 | 
			
		||||
@ -194,6 +194,21 @@ module.exports = withPlausibleProxy()({
 | 
			
		||||
        source: '/top/cowboys/:when',
 | 
			
		||||
        destination: '/top/cowboys',
 | 
			
		||||
        permanent: true
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        source: '/~:sub/top/cowboys',
 | 
			
		||||
        destination: '/top/cowboys',
 | 
			
		||||
        permanent: true
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        source: '/~:sub/top/stackers/:when*',
 | 
			
		||||
        destination: '/top/stackers/:when*',
 | 
			
		||||
        permanent: true
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        source: '/~:sub/top/territories/:when*',
 | 
			
		||||
        destination: '/top/territories/:when*',
 | 
			
		||||
        permanent: true
 | 
			
		||||
      }
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user