1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Bring back community redirect (#21971)

* add back

* adding community_redirect to page context based on parent

* update to use parentProduct

* bring back the link-secondary and text-bold
This commit is contained in:
Grace Park
2021-10-07 11:58:31 -07:00
committed by GitHub
parent 42658ba4a8
commit 9dd8ed7398
8 changed files with 42 additions and 14 deletions

View File

@@ -62,6 +62,10 @@ export type MainContextT = {
article?: BreadcrumbT
}
activeProducts: Array<ProductT>
community_redirect: {
name: string
href: string
}
currentProduct?: ProductT
currentLayoutName: string
isHomepageVersion: boolean
@@ -110,6 +114,7 @@ export const getMainContext = (req: any, res: any): MainContextT => {
return {
breadcrumbs: req.context.breadcrumbs || {},
activeProducts: req.context.activeProducts,
community_redirect: req.context.page?.community_redirect || {},
currentProduct: req.context.productMap[req.context.currentProduct] || null,
currentLayoutName: req.context.currentLayoutName,
isHomepageVersion: req.context.page?.documentType === 'homepage',

View File

@@ -7,18 +7,7 @@ import { useMainContext } from 'components/context/MainContext'
export const Support = () => {
const { isEnterprise } = useVersion()
const { t } = useTranslation('support')
const { relativePath } = useMainContext()
let updatedCommunityLink = ''
if (
relativePath?.startsWith('codespaces') ||
relativePath?.startsWith('discussions') ||
relativePath?.startsWith('sponsors')
) {
const product = relativePath.substring(0, relativePath.indexOf('/'))
updatedCommunityLink = `https://github.com/github/feedback/discussions/categories/${product}-feedback`
}
const { community_redirect } = useMainContext()
return (
<div>
@@ -26,11 +15,13 @@ export const Support = () => {
<div className="mb-2">
<a
id="ask-community"
href={updatedCommunityLink === '' ? 'https://github.community/' : updatedCommunityLink}
href={community_redirect.href || 'https://github.community/'}
className="Link—secondary text-bold"
>
<PeopleIcon size="small" className="octicon mr-1" />
{updatedCommunityLink === '' ? t`ask_community` : 'Provide GitHub Feedback'}
{Object.keys(community_redirect).length === 0
? t`ask_community`
: community_redirect.name}
</a>
</div>
<div>

View File

@@ -24,6 +24,9 @@ featuredLinks:
- /codespaces/setting-up-your-codespace/personalizing-codespaces-for-your-account
popularHeading: Set up your project
product_video: 'https://www.youtube-nocookie.com/embed/_W9B7qc9lVc'
community_redirect:
name: 'Provide GitHub Feedback'
href: 'https://github.com/github/feedback/discussions/categories/codespaces-feedback'
redirect_from:
- /github/developing-online-with-github-codespaces
- /github/developing-online-with-codespaces

View File

@@ -28,6 +28,9 @@ product_video: 'https://www.youtube-nocookie.com/embed/IpBw2SJkFyk'
layout: product-landing
versions:
fpt: '*'
community_redirect:
name: 'Provide GitHub Feedback'
href: 'https://github.com/github/feedback/discussions/categories/discussions-feedback'
children:
- /quickstart
- /guides

View File

@@ -7,6 +7,9 @@ versions:
topics:
- Repositories
shortTitle: Automated release notes
community_redirect:
name: 'Provide GitHub Feedback'
href: 'https://github.com/github/feedback/discussions/categories/releases-feedback'
---
{% note %}

View File

@@ -28,6 +28,9 @@ featuredLinks:
layout: product-landing
versions:
fpt: '*'
community_redirect:
name: 'Provide GitHub Feedback'
href: 'https://github.com/github/feedback/discussions/categories/sponsors-feedback'
children:
- /getting-started-with-github-sponsors
- /sponsoring-open-source-contributors

View File

@@ -149,6 +149,13 @@ export const schema = {
interactive: {
type: 'boolean',
},
community_redirect: {
type: 'object',
properties: {
name: 'string',
href: 'string',
},
},
// Platform-specific content preference
defaultPlatform: {
type: 'string',

View File

@@ -195,6 +195,19 @@ class Page {
context.relativePath = this.relativePath
const html = await renderContent(this.markdown, context)
// Adding community_redirect for Discussions, Sponsors, and Codespaces - request from Product
if (
this.parentProduct &&
(this.parentProduct.id === 'discussions' ||
this.parentProduct.id === 'sponsors' ||
this.parentProduct.id === 'codespaces')
) {
this.community_redirect = {
name: 'Provide GitHub Feedback',
href: `https://github.com/github/feedback/discussions/categories/${this.parentProduct.id}-feedback`,
}
}
// product frontmatter may contain liquid
if (this.product) {
this.product = await renderContent(this.rawProduct, context)