-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Improve documentation sidesheet #9724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
d593942
fe57f6b
d405fa0
c213c2c
4dfc0a3
e1fe778
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="react-scripts" /> | ||
declare module "rehype-urls"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,15 @@ import React from "react"; | |
import { FormattedMessage } from "react-intl"; | ||
import styled from "styled-components"; | ||
import { useToggle } from "react-use"; | ||
import urls from "rehype-urls"; | ||
import type { PluggableList } from "react-markdown/lib/react-markdown"; | ||
|
||
import useDocumentation from "hooks/services/useDocumentation"; | ||
import { LoadingPage } from "components"; | ||
import { SideView } from "components/SideView"; | ||
import { Markdown } from "components/Markdown"; | ||
import { DestinationDefinition, SourceDefinition } from "core/domain/connector"; | ||
import { useConfig } from "config"; | ||
|
||
type IProps = { | ||
selectedService: SourceDefinition | DestinationDefinition; | ||
|
@@ -47,8 +50,18 @@ const Instruction: React.FC<IProps> = ({ | |
documentationUrl, | ||
}) => { | ||
const [isSideViewOpen, setIsSideViewOpen] = useToggle(false); | ||
const config = useConfig(); | ||
const { data: docs, isLoading } = useDocumentation(documentationUrl); | ||
|
||
const removeBaseUrl = (url: { path: string }) => { | ||
if (url.path.match(/^..\/..\/.*/)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Could you give an example of what URLs we're trying to rewrite here? This currently matches everything beginning with two arbitrary letters than slash then two more arbitrary letters? My feeling of gut is we're trying to rewrite specifically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Fixed |
||
return url.path.replace(/^..\/..\//, `${config.integrationUrl}/`); | ||
} | ||
return url.path; | ||
}; | ||
|
||
const urlReplacerPlugin: PluggableList = [[urls, removeBaseUrl]]; | ||
|
||
return ( | ||
<> | ||
{isSideViewOpen && ( | ||
|
@@ -70,7 +83,7 @@ const Instruction: React.FC<IProps> = ({ | |
{isLoading ? ( | ||
<LoadingPage /> | ||
) : docs ? ( | ||
<Markdown content={docs} /> | ||
<Markdown content={docs} rehypePlugins={urlReplacerPlugin} /> | ||
) : ( | ||
<FormattedMessage id="docs.notFoundError" /> | ||
)} | ||
|
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.