Skip to content

Commit

Permalink
🐛 Fix endpoint layout
Browse files Browse the repository at this point in the history
Remark plugin was causing sections to be rendered before slots were used, which was affecting our layout.
Change to use a rehype plugin so HTML is transformed instead of transforming MDX.

Test plan: Expect guides layout and table of contents to be unaffected.
  • Loading branch information
MeganSteenkamp committed Oct 18, 2023
1 parent 92b408d commit 580fd75
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
10 changes: 6 additions & 4 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { defineConfig } from 'astro/config';
import flexsearchPlugin from './src/plugins/flexsearch';

import tailwind from '@astrojs/tailwind';

// Remark
import remarkSectionize from 'remark-sectionize';
// Remark plugins
import { mermaid } from './src/plugins/mermaid';

// Rehype plugins
import rehypeSectionize from '@hbsnow/rehype-sectionize';

// https://astro.build/config
import vue from '@astrojs/vue';
import mdx from '@astrojs/mdx';
Expand All @@ -20,7 +21,8 @@ export default defineConfig({
mdx(),
],
markdown: {
remarkPlugins: [remarkSectionize, mermaid],
remarkPlugins: [ mermaid ],
rehypePlugins: [ rehypeSectionize ],
shikiConfig: {
// Choose from Shiki's built-in themes (or add your own)
// https://github.com/shikijs/shiki/blob/main/docs/themes.md
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@babel/eslint-parser": "^7.14.7",
"@babel/eslint-plugin": "^7.14.5",
"@fontsource/inter": "^4.5.15",
"@hbsnow/rehype-sectionize": "^1.0.7",
"@headlessui/vue": "^1.6.0",
"@tailwindcss/typography": "^0.5.8",
"astro": "^3.2.2",
Expand All @@ -37,7 +38,6 @@
"path": "^0.12.7",
"remark-html": "^15.0.2",
"remark-parse": "^10.0.1",
"remark-sectionize": "^1.1.1",
"tailwindcss": "^3.1.8",
"unified": "^10.1.2",
"unist-util-find-after": "^4.0.1",
Expand Down
59 changes: 32 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,15 @@
resolved "https://registry.yarnpkg.com/@fontsource/inter/-/inter-4.5.15.tgz#eed1873d68755d3b52d6fcfcfa3493118430a512"
integrity sha512-FzleM9AxZQK2nqsTDtBiY0PMEVWvnKnuu2i09+p6DHvrHsuucoV2j0tmw+kAT3L4hvsLdAIDv6MdGehsPIdT+Q==

"@hbsnow/rehype-sectionize@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@hbsnow/rehype-sectionize/-/rehype-sectionize-1.0.7.tgz#fe1d77b78ecfff731a222ab134d3924646faea98"
integrity sha512-twbVxCFf4YwgTm6FIdGtHfJ14vvIHedk2fqZTpE3X6+vszEeZlMTy7tOyI9KaP/6S2DN2Jnk7zZGtZANTD+vEg==
dependencies:
hast-util-heading "^2.0.1"
hast-util-heading-rank "^2.1.1"
rehype "^12.0.1"

"@headlessui/vue@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@headlessui/vue/-/vue-1.6.0.tgz#e8242a0fb43fa2f7a0a82f1673c2ca221575a48d"
Expand Down Expand Up @@ -3307,6 +3316,29 @@ hast-util-from-parse5@^7.0.0:
vfile-location "^4.0.0"
web-namespaces "^2.0.0"

hast-util-heading-rank@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/hast-util-heading-rank/-/hast-util-heading-rank-2.1.1.tgz#063b43b9cfb56a1a8ded84dd68d8af69e8864545"
integrity sha512-iAuRp+ESgJoRFJbSyaqsfvJDY6zzmFoEnL1gtz1+U8gKtGGj1p0CVlysuUAUjq95qlZESHINLThwJzNGmgGZxA==
dependencies:
"@types/hast" "^2.0.0"

hast-util-heading@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/hast-util-heading/-/hast-util-heading-2.0.1.tgz#dde59d0a99efd9c913a5fd4b81e8551234b85318"
integrity sha512-nwRggTanShzHRYMUX46lm6pbJ2c1+TUQCETahENb6yR6c8ro8MkE0hRJm8G0IqAZl35ONgJiW8RC8+D3484vYg==
dependencies:
"@types/hast" "^2.0.0"
hast-util-is-element "^2.0.0"

hast-util-is-element@^2.0.0:
version "2.1.3"
resolved "https://registry.yarnpkg.com/hast-util-is-element/-/hast-util-is-element-2.1.3.tgz#cd3279cfefb70da6d45496068f020742256fc471"
integrity sha512-O1bKah6mhgEq2WtVMk+Ta5K7pPMqsBBlmzysLdcwKVrqzZQ0CHqUPiIVspNhAG1rvxpvJjtGee17XfauZYKqVA==
dependencies:
"@types/hast" "^2.0.0"
"@types/unist" "^2.0.0"

hast-util-parse-selector@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-3.1.0.tgz#a519e27e8b61bd5a98fad494ed06131ce68d9c3f"
Expand Down Expand Up @@ -5530,14 +5562,6 @@ remark-rehype@^10.0.0, remark-rehype@^10.1.0:
mdast-util-to-hast "^12.1.0"
unified "^10.0.0"

remark-sectionize@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/remark-sectionize/-/remark-sectionize-1.1.1.tgz#68d5267938e2a83ecfa32c933913a2bb139d0dd3"
integrity sha512-++GBmbsoeQrMBWn6jf3mj0bRq3DR8LnQPJo7u5faQ9JAJ5GeAu2uve8NoW+vgvhnuAv0GYS8hGb2+kqa+8mnpg==
dependencies:
unist-util-find-after "^2.0.2"
unist-util-visit-parents "^2.0.1"

remark-smartypants@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/remark-smartypants/-/remark-smartypants-2.0.0.tgz#836cff43ec139b2e5ec9e488d80596ed677d1cb2"
Expand Down Expand Up @@ -6337,13 +6361,6 @@ unist-builder@^3.0.0:
dependencies:
"@types/unist" "^2.0.0"

unist-util-find-after@^2.0.2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/unist-util-find-after/-/unist-util-find-after-2.0.4.tgz#3fcccf0df3a2e7291fa119224c0f22158357cc10"
integrity sha512-zo0ShIr+E/aU9xSK7JC9Kb+WP9seTFCuqVYdo5+HJSjN009XMfhiA1FIExEKzdDP1UsgvKGleGlB/pSdTSqZww==
dependencies:
unist-util-is "^3.0.0"

unist-util-find-after@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/unist-util-find-after/-/unist-util-find-after-4.0.1.tgz#80c69c92b0504033638ce11973f4135f2c822e2d"
Expand All @@ -6357,11 +6374,6 @@ unist-util-generated@^2.0.0:
resolved "https://registry.yarnpkg.com/unist-util-generated/-/unist-util-generated-2.0.0.tgz#86fafb77eb6ce9bfa6b663c3f5ad4f8e56a60113"
integrity sha512-TiWE6DVtVe7Ye2QxOVW9kqybs6cZexNwTwSMVgkfjEReqy/xwGpAXb99OxktoWwmL+Z+Epb0Dn8/GNDYP1wnUw==

unist-util-is@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-3.0.0.tgz#d9e84381c2468e82629e4a5be9d7d05a2dd324cd"
integrity sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==

unist-util-is@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-5.1.1.tgz#e8aece0b102fa9bc097b0fef8f870c496d4a6236"
Expand Down Expand Up @@ -6418,13 +6430,6 @@ unist-util-visit-children@^2.0.0:
dependencies:
"@types/unist" "^2.0.0"

unist-util-visit-parents@^2.0.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz#25e43e55312166f3348cae6743588781d112c1e9"
integrity sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==
dependencies:
unist-util-is "^3.0.0"

unist-util-visit-parents@^5.0.0, unist-util-visit-parents@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-5.1.1.tgz#868f353e6fce6bf8fa875b251b0f4fec3be709bb"
Expand Down

0 comments on commit 580fd75

Please sign in to comment.