Skip to content

Commit 60ba309

Browse files
committed
Fix rendering issues with python and /docs/ changes
1 parent 26be358 commit 60ba309

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

src/pages/docs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function getStaticProps({ params }) {
3838
)
3939
const query = {
4040
"@type": "Page",
41-
slug: "/docs/get-started",
41+
slug: "get-started",
4242
}
4343
const docs = await client.getDocument({
4444
"@type": "Page",

src/pages/docs/python.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export default function Python(props) {
7777

7878
export async function getStaticProps(context) {
7979
const client = new TerminusClient.WOQLClient(
80-
"https://cloud.terminusdb.com/TerminatorsX",
80+
process.env.TERMINUSDB_API_ENDPOINT,
8181
{
8282
83-
organization: "TerminatorsX",
84-
db: "terminusCMS_docs",
83+
organization: process.env.TERMINUSDB_TEAM,
84+
db: process.env.TERMINUSDB_DB,
8585
token: process.env.TERMINUSDB_API_TOKEN,
8686
}
8787
)

src/pages/index.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* eslint-disable @next/next/no-img-element */
2+
const TerminusClient = require("@terminusdb/terminusdb-client")
3+
import Image from "next/image"
4+
import { Inter } from "next/font/google"
5+
const inter = Inter({ subsets: ["latin"] })
6+
import axios from "axios"
7+
import "flowbite"
8+
import { getHtml, getSubTitle } from "../utils"
9+
import menu from "../menu.json"
10+
import { Layout } from "../components/_layout"
11+
import { renderMarkdown } from "../lib/markdown"
12+
13+
export default function Home(props: { menu: any[]; entry: any[] }) {
14+
let html = getHtml(props.entry)
15+
let displayElement = <div dangerouslySetInnerHTML={{ __html: html }} />
16+
return (
17+
<Layout
18+
menu={props.menu}
19+
entry={props.entry}
20+
displayElement={displayElement}
21+
heading={props.entry.document?.title?.value ?? ""}
22+
subtitle={getSubTitle(props.entry.document)}
23+
seo_metadata={props.entry.document?.seo_metadata}
24+
/>
25+
)
26+
}
27+
28+
export async function getStaticProps({ params }) {
29+
// Connect and configure the TerminusClient
30+
const client = new TerminusClient.WOQLClient(
31+
process.env.TERMINUSDB_API_ENDPOINT,
32+
{
33+
user: process.env.TERMINUSDB_USER,
34+
organization: process.env.TERMINUSDB_TEAM,
35+
db: process.env.TERMINUSDB_DB,
36+
token: process.env.TERMINUSDB_API_TOKEN,
37+
}
38+
)
39+
const query = {
40+
"@type": "Page",
41+
slug: "get-started",
42+
}
43+
const docs = await client.getDocument({
44+
"@type": "Page",
45+
as_list: true,
46+
query: query,
47+
})
48+
const docResult = docs[0]
49+
let html = await renderMarkdown(docResult?.["body"]?.["value"] ?? "")
50+
const entry = { html: html, document: docResult ?? null }
51+
return { props: { menu: menu, entry: entry } }
52+
}

0 commit comments

Comments
 (0)