Skip to content

Commit

Permalink
replace starry-night with shiki
Browse files Browse the repository at this point in the history
  • Loading branch information
souporserious committed Oct 3, 2023
1 parent 16ff045 commit 27366fd
Show file tree
Hide file tree
Showing 19 changed files with 185 additions and 17,816 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-islands-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mdxts": patch
---

Replace starry-night with shiki.
33 changes: 32 additions & 1 deletion mdxts/components/SiblingNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
import * as React from 'react'
import { getPathData } from '../utils'

/** Returns the active and sibling data based on the active pathname. */
export function getPathData(
/** The collected data from a source. */
data: Record<string, any>,

/** The pathname of the active page. */
pathname: string[]
) {
const allData = Object.values(data) as any[]
const index = Object.keys(data).findIndex((dataPathname) =>
dataPathname.includes(pathname.join('/'))
)

function getSiblingPath(startIndex: number, direction: number) {
const siblingIndex = startIndex + direction
const siblingPath = allData[siblingIndex]

if (siblingPath?.pathname === null) {
return getSiblingPath(siblingIndex, direction)
}

return siblingPath || null
}

return {
active: allData[index] || null,
previous: getSiblingPath(index, -1),
next: getSiblingPath(index, 1),
}
}

/** Renders previous and next links. */
export function SiblingNavigation({
data,
pathname,
Expand Down
Loading

1 comment on commit 27366fd

@vercel
Copy link

@vercel vercel bot commented on 27366fd Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.