-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add LLM helper component to docs (#2340)
* add llm helper component * concat wasp url
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |