Files
supabase/apps/www/pages/alternatives/[slug].tsx
supabase-vercel-tedd[bot] 1f6ee9e8b9 chore(www): replace markdown-toc with the local TOC helper to drop vulnerable toml (#53879)
## Problem

`markdown-toc@1.2.0` (its latest release) depends on
`gray-matter@2.1.1`, which pins `toml@^2.3.2`. That leaves `toml@2.3.6`
in the lockfile, and `pnpm audit` flags it with several high-severity
advisories (fixed in `>=5.0.1`). Neither parent has a release that moves
off toml 2.x, so a lockfile-only bump or a temporary override can't
remove it.

## Solution

The customer story (`/customers/[slug]`) and alternatives
(`/alternatives/[slug]`) pages built a `toc` prop at build time, but
neither page nor `LayoutComparison` ever read it. This PR removes that
prop, the `markdown-toc` dependency, and `apps/www/lib/toc.ts`, which
had no other callers. With `markdown-toc` gone from
`apps/www/package.json`, `gray-matter@2.1.1` and `toml` leave the
dependency tree. www keeps using `gray-matter@4.0.3` directly. The
lockfile change only removes entries.

## Review instructions

1. Run `pnpm why toml --recursive` and check it finds no `toml`.
2. Run `pnpm tsx scripts/fix-audit-vulnerability.ts --json` and check
`toml` is not in `vulnerabilities`.
3. Open a customer story on the preview, for example
`/customers/asap-work`, and an alternatives page, for example
`/alternatives/supabase-vs-auth0`. Each page builds and renders as it
does on production.

Checks run: `pnpm install --frozen-lockfile`, `pnpm run typecheck` in
`apps/www` (next typegen + tsc), eslint on both changed pages (no
errors), and `oxfmt --check` on the changed files.

## Checklist

Check all before review:

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)


[FE-5192](https://linear.app/supabase/issue/FE-5192/bump-a-single-vulnerable-dependency)

## Feedback for Tedd

To ask Tedd for a change to this PR, reply in Tedd's session on
[FE-5192](https://linear.app/supabase/issue/FE-5192/bump-a-single-vulnerable-dependency).
Tedd doesn't read comments on this PR.

---------

Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
2026-11-24 16:44:02 +01:00

79 lines
2.1 KiB
TypeScript

import matter from 'gray-matter'
import authors from 'lib/authors.json'
import LayoutComparison from '~/layouts/comparison'
import mdxComponents from '~/lib/mdx/mdxComponents'
import { mdxSerialize } from '~/lib/mdx/mdxSerialize'
import { getAllPostSlugs, getPostdata, getSortedPosts } from '~/lib/posts'
// import all components used in blog articles here
// for instance, if you use a button, you must add `Button` in the components object below.
export async function getStaticPaths() {
const paths = getAllPostSlugs('_alternatives')
return {
paths,
fallback: false,
}
}
export async function getStaticProps({ params }: any) {
const filePath = `${params.slug}`
const postContent = await getPostdata(filePath, '_alternatives')
const { data, content } = matter(postContent)
const mdxSource: any = await mdxSerialize(content)
const relatedPosts = getSortedPosts({
directory: '_alternatives',
limit: 5,
tags: mdxSource.scope.tags,
})
const allPosts = getSortedPosts({ directory: '_alternatives' })
const currentIndex = allPosts
.map(function (e) {
return e.slug
})
.indexOf(filePath)
const nextPost = allPosts[currentIndex + 1]
const prevPost = allPosts[currentIndex - 1]
return {
props: {
prevPost: currentIndex === 0 ? null : prevPost ? prevPost : null,
nextPost: currentIndex === allPosts.length ? null : nextPost ? nextPost : null,
relatedPosts,
blog: {
slug: `${params.slug}`,
content: mdxSource,
source: content,
...data,
},
},
}
}
function BlogPostPage(props: any) {
// @ts-ignore
// const content = hydrate(props.blog.content, { components })
// const content = props.blog.content
const authorArray = props.blog.author.split(',')
const author = []
for (let i = 0; i < authorArray.length; i++) {
author.push(
// @ts-ignore
authors.find((authors: string) => {
// @ts-ignore
return authors.author_id === authorArray[i]
})
)
}
return <LayoutComparison components={mdxComponents()} props={props} />
}
export default BlogPostPage