diff --git a/site/src/components/Image.jsx b/site/src/components/Image.jsx
new file mode 100644
index 0000000..67ec69b
--- /dev/null
+++ b/site/src/components/Image.jsx
@@ -0,0 +1,11 @@
+import React from 'react';
+import config from '../../next.config.js';
+
+const MyImage = ({ src, width, height, ...props }) => {
+ const _src = `${config.basePath}${src}`
+ return (
+
+ );
+};
+
+export default MyImage;
diff --git a/site/src/components/Rehype.jsx b/site/src/components/Rehype.jsx
index 376ea83..bbc44ac 100644
--- a/site/src/components/Rehype.jsx
+++ b/site/src/components/Rehype.jsx
@@ -1,19 +1,25 @@
import React from 'react';
import unified from 'unified';
+import orgParse from 'uniorg-parse';
+import org2rehype from 'uniorg-rehype';
import rehype2react from 'rehype-react';
+import toc from '@jsdevtools/rehype-toc';
import Link from './Link';
+import Image from './Image';
// we use rehype-react to process hast and transform it to React
// component, which allows as replacing some of components with custom
// implementation. e.g., we can replace all links to use
// `next/link`.
-const processor = unified().use(rehype2react, {
+const processor = unified()
+ .use(rehype2react, {
createElement: React.createElement,
Fragment: React.Fragment,
components: {
a: Link,
+ img: Image,
},
});
diff --git a/site/src/lib/api.js b/site/src/lib/api.js
index 5f3f483..b667480 100644
--- a/site/src/lib/api.js
+++ b/site/src/lib/api.js
@@ -1,4 +1,5 @@
import * as path from 'path';
+import toc from '@jsdevtools/rehype-toc';
import trough from 'trough';
import toVFile from 'to-vfile';
import findDown from 'vfile-find-down';
@@ -73,6 +74,7 @@ function populateBacklinks(files) {
backlinks[file.data.slug] || new Set();
file.data.links.forEach((other) => {
+ if (other === file.data.slug) { return; }
backlinks[other] = backlinks[other] || new Set();
backlinks[other].add(file.data.slug);
});
diff --git a/site/src/lib/orgToHtml.js b/site/src/lib/orgToHtml.js
index ef00e7e..b2c9e5f 100644
--- a/site/src/lib/orgToHtml.js
+++ b/site/src/lib/orgToHtml.js
@@ -5,6 +5,7 @@ import org2rehype from 'uniorg-rehype';
import extractKeywords from 'uniorg-extract-keywords';
import { uniorgSlug } from 'uniorg-slug';
import { visitIds } from 'orgast-util-visit-ids';
+import toc from '@jsdevtools/rehype-toc'
const processor = unified()
.use(orgParse)
@@ -12,6 +13,7 @@ const processor = unified()
.use(uniorgSlug)
.use(extractIds)
.use(org2rehype)
+ .use(toc)
.use(toJson);
export default async function orgToHtml(file) {
diff --git a/site/src/styles/globals.css b/site/src/styles/globals.css
index affc843..1beb6e1 100644
--- a/site/src/styles/globals.css
+++ b/site/src/styles/globals.css
@@ -1,6 +1,5 @@
html,
-body {
- padding: 0;
+body { padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
@@ -32,3 +31,17 @@ code {
background-color: #eee;
}
+
+ol {
+ counter-reset: item;
+ list-style: none;
+}
+ol>li {
+ counter-increment: item;
+}
+ol>li::before {
+ content: counters(item, '.') '. ';
+}
+img {
+ max-width: 100%;
+}