Commit fb605f2e by PLN (Algolia)

feat: Hydras code highlighted

parent 5627b9eb
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-player": "^2.9.0", "react-player": "^2.9.0",
"react-syntax-highlighter": "^15.4.3",
"remark": "^13.0.0", "remark": "^13.0.0",
"remark-html": "^13.0.1" "remark-html": "^13.0.1"
}, },
......
import SyntaxHighlighter from "react-syntax-highlighter";
import Head from "next/head"; import Head from "next/head";
import Layout from "../../components/layout"; import Layout from "../../components/layout";
import HydraSynth from "../../components/hydra"; import HydraSynth from "../../components/hydra";
import Date from "../../components/date"; import Date from "../../components/date";
const https = require('https') const https = require("https");
import utilStyles from "../../styles/utils.module.css"; import utilStyles from "../../styles/utils.module.css";
import { getAllHydraIds, getHydraData } from "../../lib/hydras"; import { getAllHydraIds, getHydraData } from "../../lib/hydras";
...@@ -12,7 +13,7 @@ export async function getStaticProps({ params }) { ...@@ -12,7 +13,7 @@ export async function getStaticProps({ params }) {
const response = await fetch(hydraData.source); const response = await fetch(hydraData.source);
const source = await response.text(); const source = await response.text();
const sourceCode = source.replace(/(?:\r\n|\r|\n)/g, '<br>'); const sourceCode = source.replace(/(?:\r\n|\r|\n)/g, "<br>");
console.log(sourceCode); console.log(sourceCode);
hydraData.source = source; hydraData.source = source;
...@@ -20,7 +21,7 @@ export async function getStaticProps({ params }) { ...@@ -20,7 +21,7 @@ export async function getStaticProps({ params }) {
return { return {
props: { props: {
hydraData, hydraData,
sourceCode sourceCode,
}, },
}; };
} }
...@@ -41,12 +42,15 @@ export default function Hydra({ hydraData, sourceCode }) { ...@@ -41,12 +42,15 @@ export default function Hydra({ hydraData, sourceCode }) {
</Head> </Head>
<article> <article>
<h1 className={utilStyles.headingXl}>{hydraData.title}</h1> <h1 className={utilStyles.headingXl}>{hydraData.title}</h1>
<p className="code" dangerouslySetInnerHTML={{ __html: sourceCode }} /> <SyntaxHighlighter width="64em" language="javascript" wrapLongLines={true}
</article> >
<HydraSynth {hydraData.source}
</SyntaxHighlighter>
{/*<HydraSynth
width={700} width={700}
height={475} height={475}
source={hydraData.source}/> source={hydraData.source}/>*/}
</article>
</Layout> </Layout>
); );
} }
...@@ -68,6 +68,7 @@ h1 a, h2 a, h3 a, h4 a, h5 a { ...@@ -68,6 +68,7 @@ h1 a, h2 a, h3 a, h4 a, h5 a {
text-decoration: underline; text-decoration: underline;
} }
.player-wrapper { .player-wrapper {
padding: 12em 0; padding: 12em 0;
position: relative; position: relative;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment