Skip to content

Commit e74d728

Browse files
Adding links to installation instructions to researcher tab
1 parent 9d405b3 commit e74d728

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/components/getstarted.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@ import { Heading } from '@/components/mdx'
2323
export const GetStarted = () => {
2424
const getstarted = React.useMemo(() => data, [])
2525
const [activeIndex, setActiveIndex] = React.useState(null)
26+
27+
const renderTextWithLinks = (text) => {
28+
const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g
29+
const nodes = []
30+
let lastIndex = 0
31+
let match
32+
33+
while ((match = linkRegex.exec(text)) !== null) {
34+
if (match.index > lastIndex) {
35+
nodes.push(text.slice(lastIndex, match.index))
36+
}
37+
38+
nodes.push(
39+
<Link
40+
key={`${match[2]}-${match.index}`}
41+
href={match[2]}
42+
color='blue.500'
43+
isExternal
44+
textDecoration='underline'
45+
>
46+
{match[1]}
47+
</Link>,
48+
)
49+
50+
lastIndex = linkRegex.lastIndex
51+
}
52+
53+
if (lastIndex < text.length) {
54+
nodes.push(text.slice(lastIndex))
55+
}
56+
57+
return nodes
58+
}
59+
2660
return (
2761
<Box id={'getstarted'} as='section'>
2862
<Container maxW='container.lg' centerContent>
@@ -62,7 +96,7 @@ export const GetStarted = () => {
6296
{activeIndex !== null && (
6397
<Box mt={4} width='100%'>
6498
<Text fontSize={'lg'} whiteSpace='pre-line'>
65-
{getstarted[activeIndex].text}
99+
{renderTextWithLinks(getstarted[activeIndex].text)}
66100
</Text>
67101
</Box>
68102
)}

src/data/getstarted.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const GetStarted = [
3131
3232
Current implementations include instruments such as CTDs, ADCPs, Argo floats, and drifters, with several others in development.
3333
34+
See [here](https://virtualship.readthedocs.io/en/latest/#installation) for installation instructions and the [Quickstart guide](https://virtualship.readthedocs.io/en/latest/user-guide/quickstart.html) for usage guidelines.
35+
3436
Researchers are very much encouraged to contribute workflows, instrument modules, and scientific applications to co-develop the VirtualShip ecosystem as open-source software towards virtual marine fieldwork.`,
3537
},
3638
{

0 commit comments

Comments
 (0)