Skip to content

Commit

Permalink
✨ refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
yuancong-liu committed Dec 4, 2023
1 parent 8cc3b5f commit 2359659
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 140 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.0",
"rehype-toc": "^3.0.2",
"rehype-wrap": "^1.1.0",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"remark-html": "^16.0.1",
Expand Down
22 changes: 9 additions & 13 deletions src/components/pages/blog/postContent/index.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
.side-bar {
.toc-wrapper {
display: flex;
flex-shrink: 0;
width: 200px;

@media (width <= 768px) {
display: none;
}

&:not(:has(.toc-item)) {
display: none;
}
}

.toc-wrapper {
height: 100%;
height: auto;
margin: 20px 10px 60px;
font-size: 1.4rem;
color: #fdf0f0;


@media (width <= 768px) {
display: none;
}

&:not(:has(.toc-item)) {
display: none;
}
}

.toc-item {
Expand Down Expand Up @@ -85,6 +80,7 @@
position: sticky;
top: 100px;
z-index: 1;
height: fit-content;

&::after {
position: absolute;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import rehypeRaw from 'rehype-raw';
import rehypeSlug from 'rehype-slug';
import rehypeStringify from 'rehype-stringify';
import rehypeToc from 'rehype-toc';
import rehypeWrap from 'rehype-wrap';
import remarkGfm from 'remark-gfm';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
Expand Down Expand Up @@ -139,7 +138,7 @@ export const markdownToHtml = async (markdown: string) => {
headings: ['h2', 'h3'],
cssClasses: { toc: 'toc-wrapper' },
})
.use(rehypeWrap, { selector: '.toc-wrapper', wrapper: 'aside.side-bar' })
// .use(rehypeWrap, { selector: '.toc-wrapper', wrapper: 'aside.side-bar' })
.use(rehypeStringify)
.use(remarkGfm)
.process(markdown);
Expand Down
125 changes: 1 addition & 124 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2361,11 +2361,6 @@ balanced-match@^2.0.0:
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-2.0.0.tgz"
integrity sha512-1ugUSr8BHXRnK23KfuYS+gVMC3LB8QGH9W1iGtDPsNWoQbgtXSExkBu2aDR4epiGWZOjZsj6lDl/N/AqqTC3UA==

bcp-47-match@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/bcp-47-match/-/bcp-47-match-1.0.3.tgz#cb8d03071389a10aff2062b862d6575ffd7cd7ef"
integrity sha512-LggQ4YTdjWQSKELZF5JwchnBa1u0pIQSZf5lSdOHEdbVP55h0qICA/FUp3+W99q0xqxYa1ZQizTUH87gecII5w==

bcp-47@1:
version "1.0.8"
resolved "https://registry.npmjs.org/bcp-47/-/bcp-47-1.0.8.tgz"
Expand Down Expand Up @@ -2623,11 +2618,6 @@ colorette@^2.0.20:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a"
integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==

comma-separated-tokens@^1.0.0:
version "1.0.8"
resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz#632b80b6117867a158f1080ad498b2fbe7e3f5ea"
integrity sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==

comma-separated-tokens@^2.0.0:
version "2.0.3"
resolved "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz"
Expand Down Expand Up @@ -2753,11 +2743,6 @@ css-select@^5.1.0:
domutils "^3.0.1"
nth-check "^2.0.1"

css-selector-parser@^1.0.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/css-selector-parser/-/css-selector-parser-1.4.1.tgz#03f9cb8a81c3e5ab2c51684557d5aaf6d2569759"
integrity sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==

css-tree@^2.2.1, css-tree@^2.3.1:
version "2.3.1"
resolved "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz"
Expand Down Expand Up @@ -2917,11 +2902,6 @@ dir-glob@^3.0.1:
dependencies:
path-type "^4.0.0"

direction@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/direction/-/direction-1.0.4.tgz#2b86fb686967e987088caf8b89059370d4837442"
integrity sha512-GYqKi1aH7PJXxdhTeZBFrg8vUBeKXi+cNprXsC1kpJcbcVnV9wBsrOu1cQEdG0WeQwlfHiy3XvnKfIrJ2R0NzQ==

doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz"
Expand Down Expand Up @@ -3979,11 +3959,6 @@ hast-util-from-parse5@^8.0.0:
vfile-location "^5.0.0"
web-namespaces "^2.0.0"

hast-util-has-property@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/hast-util-has-property/-/hast-util-has-property-1.0.4.tgz#9f137565fad6082524b382c1e7d7d33ca5059f36"
integrity sha512-ghHup2voGfgFoHMGnaLHOjbYFACKrRh9KFttdCzMCbFoBMJXiNi2+XTrPP8+q6cDJM/RSqlCfVWrjp1H201rZg==

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"
Expand All @@ -4006,11 +3981,6 @@ hast-util-heading@^2.0.1:
"@types/hast" "^2.0.0"
hast-util-is-element "^2.0.0"

hast-util-is-element@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz#3b3ed5159a2707c6137b48637fbfe068e175a425"
integrity sha512-oUmNua0bFbdrD/ELDSSEadRVtWZOf3iF6Lbv81naqsIV99RnSCieTbWuWCY8BAeEfKJTKl0gRdokv+dELutHGQ==

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"
Expand All @@ -4026,11 +3996,6 @@ hast-util-is-element@^3.0.0:
dependencies:
"@types/hast" "^3.0.0"

hast-util-parse-selector@^2.2.4:
version "2.2.5"
resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz#d57c23f4da16ae3c63b3b6ca4616683313499c3a"
integrity sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ==

hast-util-parse-selector@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz#25ab00ae9e75cbc62cf7a901f68a247eade659e2"
Expand Down Expand Up @@ -4090,26 +4055,6 @@ hast-util-sanitize@^5.0.0:
"@ungap/structured-clone" "^1.2.0"
unist-util-position "^5.0.0"

hast-util-select@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-4.0.2.tgz#ae3ef2860e02cda2ad3a2e72b47c1f5e8f44e9e7"
integrity sha512-8EEG2//bN5rrzboPWD2HdS3ugLijNioS1pqOTIolXNf67xxShYw4SQEmVXd3imiBG+U2bC2nVTySr/iRAA7Cjg==
dependencies:
bcp-47-match "^1.0.0"
comma-separated-tokens "^1.0.0"
css-selector-parser "^1.0.0"
direction "^1.0.0"
hast-util-has-property "^1.0.0"
hast-util-is-element "^1.0.0"
hast-util-to-string "^1.0.0"
hast-util-whitespace "^1.0.0"
not "^0.1.0"
nth-check "^2.0.0"
property-information "^5.0.0"
space-separated-tokens "^1.0.0"
unist-util-visit "^2.0.0"
zwitch "^1.0.0"

hast-util-to-html@^8.0.0:
version "8.0.4"
resolved "https://registry.yarnpkg.com/hast-util-to-html/-/hast-util-to-html-8.0.4.tgz#0269ef33fa3f6599b260a8dc94f733b8e39e41fc"
Expand Down Expand Up @@ -4170,11 +4115,6 @@ hast-util-to-parse5@^8.0.0:
web-namespaces "^2.0.0"
zwitch "^2.0.0"

hast-util-to-string@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-1.0.4.tgz#9b24c114866bdb9478927d7e9c36a485ac728378"
integrity sha512-eK0MxRX47AV2eZ+Lyr18DCpQgodvaS3fAQO2+b9Two9F5HEoRPhiUMNzoXArMJfZi2yieFzUBMRl3HNJ3Jus3w==

hast-util-to-string@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-3.0.0.tgz#2a131948b4b1b26461a2c8ac876e2c88d02946bd"
Expand All @@ -4192,11 +4132,6 @@ hast-util-to-text@^4.0.0:
hast-util-is-element "^3.0.0"
unist-util-find-after "^5.0.0"

hast-util-whitespace@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz#e4fe77c4a9ae1cb2e6c25e02df0043d0164f6e41"
integrity sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==

hast-util-whitespace@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/hast-util-whitespace/-/hast-util-whitespace-2.0.1.tgz#0ec64e257e6fc216c7d14c8a1b74d27d650b4557"
Expand Down Expand Up @@ -5849,11 +5784,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

not@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/not/-/not-0.1.0.tgz#c9691c1746c55dcfbe54cbd8bd4ff041bc2b519d"
integrity sha512-5PDmaAsVfnWUgTUbJ3ERwn7u79Z0dYxN9ErxCpVJJqe2RK0PJ3z+iFUxuqjwtlDDegXvtWoxD/3Fzxox7tFGWA==

npm-run-all@^4.1.5:
version "4.1.5"
resolved "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz"
Expand Down Expand Up @@ -5883,7 +5813,7 @@ npm-run-path@^5.1.0:
dependencies:
path-key "^4.0.0"

nth-check@^2.0.0, nth-check@^2.0.1:
nth-check@^2.0.1:
version "2.1.1"
resolved "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz"
integrity sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==
Expand Down Expand Up @@ -6250,13 +6180,6 @@ prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.8.1:
object-assign "^4.1.1"
react-is "^16.13.1"

property-information@^5.0.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.6.0.tgz#61675545fb23002f245c6540ec46077d4da3ed69"
integrity sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==
dependencies:
xtend "^4.0.0"

property-information@^6.0.0:
version "6.4.0"
resolved "https://registry.npmjs.org/property-information/-/property-information-6.4.0.tgz"
Expand Down Expand Up @@ -6553,15 +6476,6 @@ rehype-toc@^3.0.2:
dependencies:
"@jsdevtools/rehype-toc" "3.0.2"

rehype-wrap@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/rehype-wrap/-/rehype-wrap-1.1.0.tgz#49980d0071f8d34a7601e85ea3236ece8de2c29e"
integrity sha512-wu1bi74XSvVy2Nwy0AQd5kLwIsk+a8qgDWUxYkfvoh9qQ/CExAE3mx7OjD6r0v70bUSZF3irypeMVmpNFYj0Tg==
dependencies:
hast-util-parse-selector "^2.2.4"
hast-util-select "^4.0.0"
unist-util-visit "^2.0.3"

rehype@^12.0.1:
version "12.0.1"
resolved "https://registry.yarnpkg.com/rehype/-/rehype-12.0.1.tgz#68a317662576dcaa2565a3952e149d6900096bf6"
Expand Down Expand Up @@ -6914,11 +6828,6 @@ snake-case@^3.0.4:
resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==

space-separated-tokens@^1.0.0:
version "1.1.5"
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz#85f32c3d10d9682007e917414ddc5c26d1aa6899"
integrity sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==

space-separated-tokens@^2.0.0:
version "2.0.2"
resolved "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz"
Expand Down Expand Up @@ -7603,11 +7512,6 @@ unist-util-find-after@^5.0.0:
"@types/unist" "^3.0.0"
unist-util-is "^6.0.0"

unist-util-is@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-4.1.0.tgz#976e5f462a7a5de73d94b706bac1b90671b57797"
integrity sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==

unist-util-is@^5.0.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-5.2.1.tgz#b74960e145c18dcb6226bc57933597f5486deae9"
Expand Down Expand Up @@ -7650,14 +7554,6 @@ unist-util-stringify-position@^4.0.0:
dependencies:
"@types/unist" "^3.0.0"

unist-util-visit-parents@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz#65a6ce698f78a6b0f56aa0e88f13801886cdaef6"
integrity sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==
dependencies:
"@types/unist" "^2.0.0"
unist-util-is "^4.0.0"

unist-util-visit-parents@^5.1.1:
version "5.1.3"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-5.1.3.tgz#b4520811b0ca34285633785045df7a8d6776cfeb"
Expand All @@ -7674,15 +7570,6 @@ unist-util-visit-parents@^6.0.0:
"@types/unist" "^3.0.0"
unist-util-is "^6.0.0"

unist-util-visit@^2.0.0, unist-util-visit@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-2.0.3.tgz#c3703893146df47203bb8a9795af47d7b971208c"
integrity sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==
dependencies:
"@types/unist" "^2.0.0"
unist-util-is "^4.0.0"
unist-util-visit-parents "^3.0.0"

unist-util-visit@^4.0.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-4.1.2.tgz#125a42d1eb876283715a3cb5cceaa531828c72e2"
Expand Down Expand Up @@ -7933,11 +7820,6 @@ xml-js@^1.6.11:
dependencies:
sax "^1.2.4"

xtend@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==

y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"
Expand Down Expand Up @@ -7991,11 +7873,6 @@ yocto-queue@^0.1.0:
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zwitch@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920"
integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==

zwitch@^2.0.0, zwitch@^2.0.4:
version "2.0.4"
resolved "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz"
Expand Down

1 comment on commit 2359659

@vercel
Copy link

@vercel vercel bot commented on 2359659 Dec 4, 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.