Skip to content

Commit e6fb903

Browse files
update format
1 parent 54dca45 commit e6fb903

8 files changed

Lines changed: 63 additions & 50 deletions

File tree

components/openai/formatData.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
function formatData(data: string): string {
22
return data
33
.split("\n")
4-
.map((line, index, lines) => {
4+
.map((line) => {
55
const match = line.match(/^\**/);
66
const numAsterisks = match ? match[0].length : 0;
7-
const indentation = " ".repeat(numAsterisks - 1); // -1 because root node has 0 extra indentation
7+
8+
// Ensure the indentation level is not negative
9+
const indentationLevel = Math.max(0, numAsterisks - 1);
10+
const indentation = " ".repeat(indentationLevel);
11+
812
return indentation + line.trim();
913
})
1014
.join("\n");

components/openai/modifyMarkdown.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,5 @@ function modifyMarkdown(
4949

5050
return lines.join("\n");
5151
}
52-
function formatData(data: string): string {
53-
return data
54-
.split("\n")
55-
.map((line) => {
56-
const match = line.match(/^\**/);
57-
const numAsterisks = match ? match[0].length : 0;
58-
59-
// Ensure the indentation level is not negative
60-
const indentationLevel = Math.max(0, numAsterisks - 1);
61-
const indentation = " ".repeat(indentationLevel);
62-
63-
return indentation + line.trim();
64-
})
65-
.join("\n");
66-
}
6752

6853
export default modifyMarkdown;

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@react-three/cannon": "^6.6.0",
4646
"@react-three/drei": "^9.115.0",
4747
"@react-three/fiber": "^8.17.10",
48+
"clarity-js": "^0.7.56",
4849
"cors": "^2.8.5",
4950
"d3": "^7.9.0",
5051
"dotenv": "^16.4.5",

pages/_app.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ReactElement } from "react";
44
import { useEffect } from "react";
55
import { useRouter } from "next/router";
66
import { initGA, logPageView } from "../utils/ana";
7+
import Script from "next/script";
78
function MyApp({ Component, pageProps }: AppProps): ReactElement {
89
const router = useRouter();
910

@@ -12,6 +13,18 @@ function MyApp({ Component, pageProps }: AppProps): ReactElement {
1213
// `routeChangeComplete` won't run for the first page load unless the query string is
1314
// hydrated later on, so here we log a page view if this is the first render and
1415
// there's no query string
16+
<Script
17+
type="text/javascript"
18+
dangerouslySetInnerHTML={{
19+
__html: `
20+
(function(c,l,a,r,i,t,y){
21+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
22+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
23+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
24+
})(window, document, "clarity", "script", "ouiiyeyuum");
25+
`
26+
}}
27+
/>;
1528
if (!router.asPath.includes("?")) {
1629
logPageView();
1730
}

pages/_document.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Document, {
77
DocumentContext
88
} from "next/document";
99
import withServerStyleSheet from "../utils/withServerStyleSheet";
10+
import Script from "next/script";
11+
1012
// https://nextjs.org/docs/advanced-features/custom-document -- TypeScript example + documentation
1113

1214
export default class MyDocument extends Document {
@@ -44,7 +46,11 @@ export default class MyDocument extends Document {
4446
property="twitter:image"
4547
content="https://metatags.io/images/meta-tags.png"
4648
/>
47-
<script
49+
</Head>
50+
<body>
51+
<Main />
52+
<NextScript />
53+
<Script
4854
type="text/javascript"
4955
dangerouslySetInnerHTML={{
5056
__html: `
@@ -56,10 +62,6 @@ export default class MyDocument extends Document {
5662
`
5763
}}
5864
/>
59-
</Head>
60-
<body>
61-
<Main />
62-
<NextScript />
6365
</body>
6466
</Html>
6567
);

pages/infoPages/threedprinting.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Nav from "components/Nav";
33
import styles from "styles/Projects.module.css";
44
import Image from "next/image";
55
import Head from "next/head";
6+
import Script from "next/script";
67
export const threedprinting = () => {
78
return (
89
<div
@@ -11,18 +12,6 @@ export const threedprinting = () => {
1112
>
1213
<Head>
1314
<title>🎆DynamicApproach-Printing</title>{" "}
14-
<script
15-
type="text/javascript"
16-
dangerouslySetInnerHTML={{
17-
__html: `
18-
(function(c,l,a,r,i,t,y){
19-
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
20-
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
21-
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
22-
})(window, document, "clarity", "script", "ouiiyeyuum");
23-
`
24-
}}
25-
/>
2615
</Head>
2716
<Nav />
2817

@@ -76,6 +65,18 @@ export const threedprinting = () => {
7665
<h2 className="float-right text-nextgreen">Back&rarr;</h2>
7766
</Link>
7867
</main>
68+
<Script
69+
type="text/javascript"
70+
dangerouslySetInnerHTML={{
71+
__html: `
72+
(function(c,l,a,r,i,t,y){
73+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
74+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
75+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
76+
})(window, document, "clarity", "script", "ouiiyeyuum");
77+
`
78+
}}
79+
/>
7980
</div>
8081
);
8182
};

pages/mindmapper.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
1+
22
import { useState, useCallback, useEffect, useRef } from "react";
33
import OpenAIInput from "../components/OpenAIInput";
44
import MarkmapOutput from "../components/MarkmapOutput";
55
import Nav from "components/Nav";
66
import { logEvent, logException } from "utils/ana"; // adjust the path as needed
77
import Head from "next/head";
8-
8+
import Script from "next/script";
99
const MindMapper = () => {
1010
const [openAIResponse, setOpenAIResponse] = useState<any | null>(null);
1111
const [hasResponse, setHasResponse] = useState(false);
@@ -16,7 +16,7 @@ const MindMapper = () => {
1616
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1717
const [svgContent, setSvgContent] = useState<string | null>(null);
1818
const markmapRef = useRef<HTMLDivElement>(null);
19-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
19+
2020
const [lastInput, setLastInput] = useState("");
2121

2222
const sanitizeFilename = (filename: string) => {
@@ -58,7 +58,7 @@ const MindMapper = () => {
5858
<meta charset="UTF-8" />
5959
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6060
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
61-
<title>Mindmap</title>
61+
<title>🎆DynamicApproach-MindMap</title>
6262
<style>
6363
html, body, div.markmap svg.markmap {
6464
position: absolute;
@@ -129,18 +129,6 @@ const MindMapper = () => {
129129
>
130130
<Head>
131131
<title>🎆DynamicApproach-MindMap</title>
132-
<script
133-
type="text/javascript"
134-
dangerouslySetInnerHTML={{
135-
__html: `
136-
(function(c,l,a,r,i,t,y){
137-
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
138-
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
139-
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
140-
})(window, document, "clarity", "script", "ouiiyeyuum");
141-
`
142-
}}
143-
/>
144132
</Head>
145133
<Nav />
146134
<div className="flex flex-col-reverse md:flex-row min-h-screen">
@@ -218,6 +206,18 @@ const MindMapper = () => {
218206
</div>
219207
)}
220208
</div>
209+
<Script
210+
type="text/javascript"
211+
dangerouslySetInnerHTML={{
212+
__html: `
213+
(function(c,l,a,r,i,t,y){
214+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
215+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
216+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
217+
})(window, document, "clarity", "script", "ouiiyeyuum");
218+
`
219+
}}
220+
/>
221221
</div>
222222
);
223223
};

0 commit comments

Comments
 (0)