Skip to content

Commit

Permalink
Debug goerli preview
Browse files Browse the repository at this point in the history
Add console logs to debug goerli preview.
  • Loading branch information
michalsmiarowski committed Jul 26, 2023
1 parent 780e859 commit b6cd43b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/SubNavigationPills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ const SubNavigationPills: FC<SubNavigationPillsProps> = ({
links,
parentPathBase,
}) => {
console.log("parentPathBase: ", parentPathBase)
const linksWithTitle = links.filter((link) => !!link.title)
const activePillIndex = getActivePillIndex(linksWithTitle, parentPathBase)
console.log("activePillIndex: ", activePillIndex)
const wrapperBorderColor = useColorModeValue("gray.100", "gray.700")

return (
Expand Down Expand Up @@ -106,31 +108,44 @@ const renderPill = (pill: RouteProps, isActive = false) => (
const getPathMatches = (pills: RouteProps[], parentPathBase: string = "") => {
const pathMatches: PathMatchResult[] = []
for (let i = 0; i < pills.length; i++) {
console.log("-----------------------")
const { path, pathOverride } = pills[i]
const location = window.location.pathname
console.log("location: ", location)
console.log(
"`${parentPathBase}/${pathOverride}`: ",
`${parentPathBase}/${pathOverride}`
)
console.log("`${parentPathBase}/${path}`: ", `${parentPathBase}/${path}`)
const resolved = resolvePath(
pathOverride
? `${parentPathBase}/${pathOverride}`
: `${parentPathBase}/${path}`
)
console.log("resolved: ", resolved)
const match = matchPath({ path: resolved.pathname, end: true }, location)
console.log("match: ", match)
pathMatches.push({
index: i,
path,
pathOverride,
resolvedPath: resolved.pathname,
match,
})
console.log("-----------------------")
}
return pathMatches
}

const getActivePillIndex = (pills: RouteProps[], parentPathBase: string) => {
console.log("active pill function start")
const pathMatches = getPathMatches(pills, parentPathBase)
console.log("pathMatches: ", pathMatches)
const matchedPaths = pathMatches.filter((_) => {
return !!_.match
})

console.log("matchedPaths: ", matchedPaths)
console.log("matchedPaths.length: ", matchedPaths.length)
if (matchedPaths.length === 0) return undefined
if (matchedPaths.length === 1) return matchedPaths[0].index

Expand All @@ -143,6 +158,11 @@ const getActivePillIndex = (pills: RouteProps[], parentPathBase: string) => {
}
)

console.log(
"matchedElementWithLongestPathnameBase: ",
matchedElementWithLongestPathnameBase
)

return matchedElementWithLongestPathnameBase.index
}

Expand Down

0 comments on commit b6cd43b

Please sign in to comment.