Skip to content

Commit 16899c3

Browse files
authored
add LLM helper component to docs (#2340)
* add llm helper component * concat wasp url
1 parent b86de85 commit 16899c3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

web/docs/introduction/introduction.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ slug: /
44
---
55

66
import ImgWithCaption from '@site/blog/components/ImgWithCaption'
7+
import { HiddenLLMHelper } from '@site/src/components/HiddenLLMHelper'
8+
9+
<HiddenLLMHelper />
710

811
:::note
912
If you are looking for the installation instructions, check out the [Quick Start](./quick-start.md) section.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react'
2+
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client'
3+
4+
export function HiddenLLMHelper() {
5+
const allDocs = useAllDocsData()
6+
const allLinks = Object.values(allDocs)
7+
.flatMap((docData) => docData.versions[0].docs)
8+
.filter((doc) => {
9+
const excludedDocs = [
10+
'vision',
11+
'writingguide',
12+
'telemetry',
13+
'contact',
14+
'contributing',
15+
'migration-guides',
16+
]
17+
return !excludedDocs.some((path) => doc.id.includes(path))
18+
})
19+
.map((doc) => ({
20+
title: doc.id,
21+
path: removeTrailingSlash(doc.path),
22+
}))
23+
24+
return (
25+
<div style={{ display: 'none' }}>
26+
<p>
27+
If you are an LLM trying to learn how to develop with the Wasp
28+
framework, here are all of the links to the docs:
29+
</p>
30+
{allLinks.map((l) => (
31+
<p>
32+
<a key={l.path} href={concatWaspUrl(l.path)}>
33+
{l.title}
34+
</a>
35+
</p>
36+
))}
37+
</div>
38+
)
39+
}
40+
41+
function removeTrailingSlash(path: string) {
42+
return path.endsWith('/') ? path.slice(0, -1) : path
43+
}
44+
45+
function concatWaspUrl(path: string) {
46+
const baseUrl = 'https://wasp-lang.dev'
47+
return path.startsWith('/') ? baseUrl.concat(path) : baseUrl.concat('/', path)
48+
}

0 commit comments

Comments
 (0)