Skip to content
Merged
Prev Previous commit
Next Next commit
no html-minifier
  • Loading branch information
sreya committed Nov 27, 2024
commit 3be0552f9cd86d9feb04d87c04fa1c55d6b3b566
2 changes: 0 additions & 2 deletions offlinedocs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"archiver": "6.0.2",
"framer-motion": "^10.18.0",
"front-matter": "4.0.2",
"html-minifier": "4.0.0",
"lodash": "4.17.21",
"next": "14.2.16",
"react": "18.3.1",
Expand All @@ -30,7 +29,6 @@
"remark-gfm": "4.0.0"
},
"devDependencies": {
"@types/html-minifier": "4.0.5",
"@types/lodash": "4.17.13",
"@types/node": "20.17.6",
"@types/react": "18.3.12",
Expand Down
19 changes: 14 additions & 5 deletions offlinedocs/pages/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { MdMenu } from "react-icons/md";
import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import remarkGfm from "remark-gfm";
import { minify } from "html-minifier";

type FilePath = string;
type UrlPath = string;
Expand Down Expand Up @@ -196,10 +195,20 @@ const getNavigation = (manifest: Manifest): Nav => {
};

const removeHtmlComments = (input: string) => {
if (!input) return "";
return minify(input, {
removeComments: true,
});
if (!input) return '';

let lastResult = input;
let currentResult = '';

// Keep replacing until no more changes occur
do {
currentResult = lastResult.replace(/<!--[\s\S]*?-->/g, '');
if (currentResult === lastResult) {
break;
}
lastResult = currentResult;
} while (true);
return currentResult;
};

export const getStaticPaths: GetStaticPaths = () => {
Expand Down
Loading
Loading