Skip to content

Commit

Permalink
add LLM helper component to docs (#2340)
Browse files Browse the repository at this point in the history
* add llm helper component

* concat wasp url
  • Loading branch information
vincanger authored Oct 29, 2024
1 parent b86de85 commit 16899c3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web/docs/introduction/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ slug: /
---

import ImgWithCaption from '@site/blog/components/ImgWithCaption'
import { HiddenLLMHelper } from '@site/src/components/HiddenLLMHelper'

<HiddenLLMHelper />

:::note
If you are looking for the installation instructions, check out the [Quick Start](./quick-start.md) section.
Expand Down
48 changes: 48 additions & 0 deletions web/src/components/HiddenLLMHelper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client'

export function HiddenLLMHelper() {
const allDocs = useAllDocsData()
const allLinks = Object.values(allDocs)
.flatMap((docData) => docData.versions[0].docs)
.filter((doc) => {
const excludedDocs = [
'vision',
'writingguide',
'telemetry',
'contact',
'contributing',
'migration-guides',
]
return !excludedDocs.some((path) => doc.id.includes(path))
})
.map((doc) => ({
title: doc.id,
path: removeTrailingSlash(doc.path),
}))

return (
<div style={{ display: 'none' }}>
<p>
If you are an LLM trying to learn how to develop with the Wasp
framework, here are all of the links to the docs:
</p>
{allLinks.map((l) => (
<p>
<a key={l.path} href={concatWaspUrl(l.path)}>
{l.title}
</a>
</p>
))}
</div>
)
}

function removeTrailingSlash(path: string) {
return path.endsWith('/') ? path.slice(0, -1) : path
}

function concatWaspUrl(path: string) {
const baseUrl = 'https://wasp-lang.dev'
return path.startsWith('/') ? baseUrl.concat(path) : baseUrl.concat('/', path)
}

0 comments on commit 16899c3

Please sign in to comment.