-
Notifications
You must be signed in to change notification settings - Fork 4
Add a link for creating a GitHub issue #205
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,14 @@ | ||
.githubLink { | ||
font-style: italic; | ||
box-sizing: border-box; | ||
min-width: 0; | ||
transition: color var(--t-interaction); | ||
color: var(--ifm-font-color-base); | ||
text-align: right; | ||
|
||
&:hover, | ||
&:active, | ||
&:focus { | ||
text-decoration: underline; | ||
} | ||
} |
This file contains hidden or 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,42 @@ | ||
import styles from "./GitHubIssueLink.module.css"; | ||
|
||
export interface GitHubIssueLinkProps { | ||
pathname: string; | ||
} | ||
|
||
const getIssueTitle = function (pagePath: string) { | ||
return encodeURIComponent(`[docs] ${pagePath}: <DESCRIBE YOUR ISSUE>`); | ||
}; | ||
|
||
const getIssueBody = function (pagePath: string) { | ||
return encodeURIComponent(`## Applies To | ||
|
||
${pagePath} | ||
|
||
## Details | ||
|
||
<!-- Describe the documentation improvements you wish to see. --> | ||
|
||
## How will we know this is resolved? | ||
|
||
<!-- Briefly describe a test we can carry out. Scope this as narrowly as possible. --> | ||
|
||
## Related Issues | ||
|
||
<!-- Please make an effort to find related issues on GitHub and list them here. This makes a big difference in how we prioritize and schedule work. --> | ||
`); | ||
}; | ||
|
||
export const getReportIssueURL = function (pagePath: string): string { | ||
const mdxPath = "`" + pagePath + "`"; | ||
return `https://github.com/gravitational/teleport/issues/new?template=documentation.md&labels=documentation&title=${getIssueTitle(mdxPath)}&body=${getIssueBody(mdxPath)}`; | ||
}; | ||
export const GitHubIssueLink = function ({ pathname }: GitHubIssueLinkProps) { | ||
return ( | ||
<p className={styles.githubLink}> | ||
<a href={getReportIssueURL(pathname)} target={"_blank"}> | ||
{"Report an issue with this page"} | ||
</a> | ||
</p> | ||
); | ||
}; |
This file contains hidden or 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,45 @@ | ||
import React, {type ReactNode} from 'react'; | ||
import clsx from 'clsx'; | ||
import {ThemeClassNames} from '@docusaurus/theme-common'; | ||
import {useDoc} from '@docusaurus/plugin-content-docs/client'; | ||
import Heading from '@theme/Heading'; | ||
import MDXContent from '@theme/MDXContent'; | ||
import type {Props} from '@theme/DocItem/Content'; | ||
import {GitHubIssueLink} from "/src/components/GitHubIssueLink"; | ||
import { useLocation } from "@docusaurus/router"; | ||
|
||
/** | ||
Title can be declared inside md content or declared through | ||
front matter and added manually. To make both cases consistent, | ||
the added title is added under the same div.markdown block | ||
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120 | ||
We render a "synthetic title" if: | ||
- user doesn't ask to hide it with front matter | ||
- the markdown content does not already contain a top-level h1 heading | ||
*/ | ||
function useSyntheticTitle(): string | null { | ||
const {metadata, frontMatter, contentTitle} = useDoc(); | ||
const shouldRender = | ||
!frontMatter.hide_title && typeof contentTitle === 'undefined'; | ||
if (!shouldRender) { | ||
return null; | ||
} | ||
return metadata.title; | ||
} | ||
|
||
export default function DocItemContent({children}: Props): ReactNode { | ||
const location = useLocation(); | ||
const syntheticTitle = useSyntheticTitle(); | ||
return ( | ||
<div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}> | ||
{syntheticTitle && ( | ||
<header> | ||
<Heading as="h1">{syntheticTitle}</Heading> | ||
<GitHubIssueLink pathname={location.pathname}/> | ||
</header> | ||
)} | ||
<MDXContent>{children}</MDXContent> | ||
</div> | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it back. I think a better design choice is to left-align it (removing this style) and give it


margin-top: -25px;
so that it hugs the H1: