Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: add anchor IDs to headers

Jonathan Summers-Muir4ffd30fe6048
diff --git a/www/package-lock.json b/www/package-lock.json
index 388556bbab1..6ec38fa6a10 100644
--- a/www/package-lock.json
+++ b/www/package-lock.json
@@ -2801,9 +2801,9 @@
},
"dependencies": {
"caniuse-lite": {
- "version": "1.0.30001187",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz",
- "integrity": "sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA=="
+ "version": "1.0.30001191",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001191.tgz",
+ "integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw=="
},
"postcss": {
"version": "7.0.35",
@@ -3038,6 +3038,11 @@
}
}
},
+ "emoji-regex": {
+ "version": "6.1.1",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz",
+ "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4="
+ },
"emojis-list": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
@@ -3333,6 +3338,14 @@
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=",
"optional": true
},
+ "github-slugger": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.3.0.tgz",
+ "integrity": "sha512-gwJScWVNhFYSRDvURk/8yhcFBee6aFjye2a7Lhb2bUyRulpIoek9p0I9Kt7PT67d/nUlZbFu8L9RLiA0woQN8Q==",
+ "requires": {
+ "emoji-regex": ">=6.0.0 <=6.1.1"
+ }
+ },
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
@@ -3484,6 +3497,16 @@
}
}
},
+ "hast-util-has-property": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/hast-util-has-property/-/hast-util-has-property-1.0.4.tgz",
+ "integrity": "sha512-ghHup2voGfgFoHMGnaLHOjbYFACKrRh9KFttdCzMCbFoBMJXiNi2+XTrPP8+q6cDJM/RSqlCfVWrjp1H201rZg=="
+ },
+ "hast-util-heading-rank": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/hast-util-heading-rank/-/hast-util-heading-rank-1.0.1.tgz",
+ "integrity": "sha512-P6Hq7RCky9syMevlrN90QWpqWDXCxwIVOfQR2rK6P4GpY4bqjKEuCzoWSRORZ7vz+VgRpLnXimh+mkwvVFjbyQ=="
+ },
"hast-util-is-element": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz",
@@ -3548,6 +3571,11 @@
"zwitch": "^1.0.0"
}
},
+ "hast-util-to-string": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/hast-util-to-string/-/hast-util-to-string-1.0.4.tgz",
+ "integrity": "sha512-eK0MxRX47AV2eZ+Lyr18DCpQgodvaS3fAQO2+b9Two9F5HEoRPhiUMNzoXArMJfZi2yieFzUBMRl3HNJ3Jus3w=="
+ },
"hast-util-whitespace": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz",
@@ -3722,11 +3750,6 @@
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz",
"integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg=="
},
- "is-alphanumeric": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-alphanumeric/-/is-alphanumeric-1.0.0.tgz",
- "integrity": "sha1-Spzvcdr0wAHB2B1j0UDPU/1oifQ="
- },
"is-alphanumerical": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz",
@@ -4147,11 +4170,6 @@
"resolved": "https://registry.npmjs.org/markdown-link/-/markdown-link-0.1.1.tgz",
"integrity": "sha1-MsXGUZmmRXMWMi0eQinRNAfIx88="
},
- "markdown-table": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz",
- "integrity": "sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q=="
- },
"markdown-toc": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/markdown-toc/-/markdown-toc-1.2.0.tgz",
@@ -4223,14 +4241,6 @@
"unist-util-remove": "^2.0.0"
}
},
- "mdast-util-compact": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.4.tgz",
- "integrity": "sha512-3YDMQHI5vRiS2uygEFYaqckibpJtKq5Sj2c8JioeOQBU6INpKbdWzfyLqFFnDwEcEnRFIdMsguzs5pC1Jp4Isg==",
- "requires": {
- "unist-util-visit": "^1.1.0"
- }
- },
"mdast-util-definitions": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-1.2.5.tgz",
@@ -4647,14 +4657,14 @@
}
},
"caniuse-lite": {
- "version": "1.0.30001187",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz",
- "integrity": "sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA=="
+ "version": "1.0.30001191",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001191.tgz",
+ "integrity": "sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw=="
},
"electron-to-chromium": {
- "version": "1.3.666",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.666.tgz",
- "integrity": "sha512-/mP4HFQ0fKIX4sXltG6kfcoGrfNDZwCIyWbH2SIcVaa9u7Rm0HKjambiHNg5OEruicTl9s1EwbERLwxZwk19aw=="
+ "version": "1.3.671",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.671.tgz",
+ "integrity": "sha512-RTD97QkdrJKaKwRv9h/wGAaoR2lGxNXEcBXS31vjitgTPwTWAbLdS7cEsBK68eEQy7p6YyT8D5BxBEYHu2SuwQ=="
},
"node-releases": {
"version": "1.1.70",
@@ -5069,19 +5079,6 @@
"safe-buffer": "^5.1.1"
}
},
- "parse-entities": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz",
- "integrity": "sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg==",
- "requires": {
- "character-entities": "^1.0.0",
- "character-entities-legacy": "^1.0.0",
- "character-reference-invalid": "^1.0.0",
- "is-alphanumerical": "^1.0.0",
- "is-decimal": "^1.0.0",
- "is-hexadecimal": "^1.0.0"
- }
- },
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
@@ -6530,14 +6527,52 @@
}
}
},
+ "rehype-slug": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/rehype-slug/-/rehype-slug-4.0.1.tgz",
+ "integrity": "sha512-KIlJALf9WfHFF21icwTd2yI2IP+RQRweaxH9ChVGQwRYy36+hiomG4ZSe0yQRyCt+D/vE39LbAcOI/h4O4GPhA==",
+ "requires": {
+ "github-slugger": "^1.1.1",
+ "hast-util-has-property": "^1.0.0",
+ "hast-util-heading-rank": "^1.0.0",
+ "hast-util-to-string": "^1.0.0",
+ "unist-util-visit": "^2.0.0"
+ },
+ "dependencies": {
+ "unist-util-is": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.4.tgz",
+ "integrity": "sha512-3dF39j/u423v4BBQrk1AQ2Ve1FxY5W3JKwXxVFzBODQ6WEvccguhgp802qQLKSnxPODE6WuRZtV+ohlUg4meBA=="
+ },
+ "unist-util-visit": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz",
+ "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==",
+ "requires": {
+ "@types/unist": "^2.0.0",
+ "unist-util-is": "^4.0.0",
+ "unist-util-visit-parents": "^3.0.0"
+ }
+ },
+ "unist-util-visit-parents": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz",
+ "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==",
+ "requires": {
+ "@types/unist": "^2.0.0",
+ "unist-util-is": "^4.0.0"
+ }
+ }
+ }
+ },
"remark": {
- "version": "11.0.2",
- "resolved": "https://registry.npmjs.org/remark/-/remark-11.0.2.tgz",
- "integrity": "sha512-bh+eJgn8wgmbHmIBOuwJFdTVRVpl3fcVP6HxmpPWO0ULGP9Qkh6INJh0N5Uy7GqlV7DQYGoqaKiEIpM5LLvJ8w==",
+ "version": "13.0.0",
+ "resolved": "https://registry.npmjs.org/remark/-/remark-13.0.0.tgz",
+ "integrity": "sha512-HDz1+IKGtOyWN+QgBiAT0kn+2s6ovOxHyPAFGKVE81VSzJ+mq7RwHFledEvB5F1p4iJvOah/LOKdFuzvRnNLCA==",
"requires": {
- "remark-parse": "^7.0.0",
- "remark-stringify": "^7.0.0",
- "unified": "^8.2.0"
+ "remark-parse": "^9.0.0",
+ "remark-stringify": "^9.0.0",
+ "unified": "^9.1.0"
}
},
"remark-footnotes": {
@@ -6674,25 +6709,11 @@
}
},
"remark-parse": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-7.0.2.tgz",
- "integrity": "sha512-9+my0lQS80IQkYXsMA8Sg6m9QfXYJBnXjWYN5U+kFc5/n69t+XZVXU/ZBYr3cYH8FheEGf1v87rkFDhJ8bVgMA==",
+ "version": "9.0.0",
+ "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-9.0.0.tgz",
+ "integrity": "sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw==",
"requires": {
- "collapse-white-space": "^1.0.2",
- "is-alphabetical": "^1.0.0",
- "is-decimal": "^1.0.0",
- "is-whitespace-character": "^1.0.0",
- "is-word-character": "^1.0.0",
- "markdown-escapes": "^1.0.0",
- "parse-entities": "^1.1.0",
- "repeat-string": "^1.5.4",
- "state-toggle": "^1.0.0",
- "trim": "0.0.1",
- "trim-trailing-lines": "^1.0.0",
- "unherit": "^1.0.4",
- "unist-util-remove-position": "^1.0.0",
- "vfile-location": "^2.0.0",
- "xtend": "^4.0.1"
+ "mdast-util-from-markdown": "^0.8.0"
}
},
"remark-squeeze-paragraphs": {
@@ -6704,24 +6725,11 @@
}
},
"remark-stringify": {
- "version": "7.0.4",
- "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-7.0.4.tgz",
- "integrity": "sha512-qck+8NeA1D0utk1ttKcWAoHRrJxERYQzkHDyn+pF5Z4whX1ug98uCNPPSeFgLSaNERRxnD6oxIug6DzZQth6Pg==",
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-9.0.1.tgz",
+ "integrity": "sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==",
"requires": {
- "ccount": "^1.0.0",
- "is-alphanumeric": "^1.0.0",
- "is-decimal": "^1.0.0",
- "is-whitespace-character": "^1.0.0",
- "longest-streak": "^2.0.1",
- "markdown-escapes": "^1.0.0",
- "markdown-table": "^1.1.0",
- "mdast-util-compact": "^1.0.0",
- "parse-entities": "^1.0.2",
- "repeat-string": "^1.5.4",
- "state-toggle": "^1.0.0",
- "stringify-entities": "^2.0.0",
- "unherit": "^1.0.4",
- "xtend": "^4.0.1"
+ "mdast-util-to-markdown": "^0.6.0"
}
},
"remarkable": {
@@ -7459,12 +7467,13 @@
"integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg=="
},
"unified": {
- "version": "8.4.2",
- "resolved": "https://registry.npmjs.org/unified/-/unified-8.4.2.tgz",
- "integrity": "sha512-JCrmN13jI4+h9UAyKEoGcDZV+i1E7BLFuG7OsaDvTXI5P0qhHX+vZO/kOhz9jn8HGENDKbwSeB0nVOg4gVStGA==",
+ "version": "9.2.0",
+ "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.0.tgz",
+ "integrity": "sha512-vx2Z0vY+a3YoTj8+pttM3tiJHCwY5UFbYdiWrwBEbHmK8pvsPj2rtAX2BFfgXen8T39CJWblWRDT4L5WGXtDdg==",
"requires": {
"bail": "^1.0.0",
"extend": "^3.0.0",
+ "is-buffer": "^2.0.0",
"is-plain-obj": "^2.0.0",
"trough": "^1.0.0",
"vfile": "^4.0.0"
@@ -7514,14 +7523,6 @@
}
}
},
- "unist-util-remove-position": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.4.tgz",
- "integrity": "sha512-tLqd653ArxJIPnKII6LMZwH+mb5q+n/GtXQZo6S6csPRs5zB0u79Yw8ouR3wTw8wxvdJFhpP6Y7jorWdCgLO0A==",
- "requires": {
- "unist-util-visit": "^1.1.0"
- }
- },
"unist-util-stringify-position": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz",
@@ -7639,11 +7640,6 @@
}
}
},
- "vfile-location": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.6.tgz",
- "integrity": "sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA=="
- },
"vfile-message": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz",
diff --git a/www/package.json b/www/package.json
index 158b67b9e89..c409a54093b 100644
--- a/www/package.json
+++ b/www/package.json
@@ -29,7 +29,8 @@
"react-markdown": "^5.0.3",
"react-syntax-highlighter": "^15.3.1",
"react-transition-group": "^4.4.1",
- "remark": "11.0.2",
+ "rehype-slug": "^4.0.1",
+ "remark": "^13.0.0",
"remark-gfm": "^1.0.0",
"remark-html": "10.0.0",
"typescript": "^4.0.3",
diff --git a/www/pages/blog/[slug].tsx b/www/pages/blog/[slug].tsx
index ea57b86b094..be5aa1f60c1 100644
--- a/www/pages/blog/[slug].tsx
+++ b/www/pages/blog/[slug].tsx
@@ -17,8 +17,9 @@ import Badge from '~/components/Badge'
const components = { CodeBlock }
-const toc = require('markdown-toc')
const gfm = require('remark-gfm')
+const toc = require('markdown-toc')
+const slug = require('rehype-slug')
function BlogPostPage(props: any) {
// @ts-ignore
@@ -117,32 +118,17 @@ export async function getStaticPaths() {
fallback: false,
}
}
-// export async function getStaticProps({ params }: any) {
-// const postContent = await getPostdata(params.slug)
-// const { data, content } = matter(postContent)
-
-// return {
-// props: {
-// blog: {
-// content: content,
-// ...data,
-// toc: toc(content),
-// },
-// },
-// }
-// }
export async function getStaticProps({ params }: any) {
const postContent = await getPostdata(params.slug)
const { data, content } = matter(postContent)
- console.log(content)
-
const mdxSource: any = await renderToString(content, {
components,
scope: data,
mdxOptions: {
remarkPlugins: [gfm],
+ rehypePlugins: [slug],
},
})
@@ -160,98 +146,4 @@ export async function getStaticProps({ params }: any) {
}
}
-// // pass props to BlogPostPage component
-// export async function getStaticProps(context: any) {
-// const fs = require('fs')
-// // const html = require('remark-html')
-// // const highlight = require('remark-highlight.js')
-// // const unified = require('unified')
-// // const markdown = require('remark-parse')
-// const matter = require('gray-matter')
-
-// const slug = context.params.slug // get slug from params
-// const path = `${process.cwd()}/_blog/${slug}.mdx`
-
-// // read file content and store into rawContent variable
-// const rawContent = fs.readFileSync(path, {
-// encoding: 'utf-8',
-// })
-
-// const { data, content } = matter(rawContent) // pass rawContent to gray-matter to get data and content
-
-// // const result = await unified()
-// // .use(markdown)
-// // .use(highlight) // highlight code block
-// // .use(html)
-// // .process(content) // pass content to process)
-
-// return {
-// props: {
-// blog: {
-// toc: toc(content),
-// ...data,
-// // content: result.toString(),
-// content: content,
-// },
-// },
-// }
-// }
-
-// // generate HTML paths at build time
-// export async function getStaticPaths(context: any) {
-// const fs = require('fs')
-
-// const path = `${process.cwd()}/_blog`
-// const files = fs.readdirSync(path, 'utf-8')
-
-// const markdownFileNames = files
-// .filter((fn: any) => fn.endsWith('.mdx'))
-// .map((fn: any) => fn.replace('.mdx', ''))
-
-// return {
-// paths: markdownFileNames.map((fileName: any) => {
-// return {
-// params: {
-// slug: fileName,
-// },
-// }
-// }),
-// fallback: false,
-// }
-// }
-
-// Heading renderer solution
-// https://github.com/remarkjs/react-markdown/issues/404
-
-const flatten = (text: string, child: any) => {
- const result: any =
- typeof child === 'string'
- ? text + child
- : React.Children.toArray(child.props.children).reduce(flatten, text)
-
- return result
-}
-
-/**
- * HeadingRenderer is a custom renderer
- * It parses the heading and attaches an id to it to be used as an anchor
- */
-const HeadingRenderer = (props: any) => {
- const children = React.Children.toArray(props.children)
- const text = children.reduce(flatten, '')
- const slug = text.toLowerCase().replace(/\W/g, '-')
- return (
- <a href={'#' + slug} style={{ textDecoration: 'none' }}>
- <Space>
- <span className={blogStyles['header']}>
- {React.createElement('h' + props.level, { id: slug }, [
- props.children,
- <IconLink size="small" className="ml-2 hidden" />,
- ])}
- </span>
- </Space>
- </a>
- )
-}
-
export default BlogPostPage