Skip to content

Commit

Permalink
Display the outdated docs banner (#1629)
Browse files Browse the repository at this point in the history
* Always display the outdated docs banner

* Disable announcement banner
  • Loading branch information
ppcano authored Jun 25, 2024
1 parent b46c060 commit 26ee96a
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 25 deletions.
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});

const shouldAnnouncementBannerBeShown = true;
const shouldAnnouncementBannerBeShown = false;

const plugins = [
'gatsby-transformer-sharp',
Expand Down
7 changes: 5 additions & 2 deletions src/components/shared/page-info/page-info.module.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
.container {
margin-bottom: 20px;
margin-top: 115px;
//margin-top: 115px;
margin-top: 165px;

@include xl-down {
margin-top: 160px;
}

@include lg-down {
margin-top: 205px;
margin-bottom: 20px;
}

@include sm-down {
margin-top: 230px;
//margin-top: 230px;
margin-top: 240px;
}

&.wide {
Expand Down
24 changes: 7 additions & 17 deletions src/components/shared/version-banner/version-banner.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import React from 'react';
import { LATEST_VERSION } from 'utils/versioning';
// import { LATEST_VERSION } from 'utils/versioning';

import styles from './version-banner.module.scss';

export const VersionBanner = ({ version, versions }) => (
export const VersionBanner = ({ canonicalUrl }) => (
<div className={styles.wrapper}>
<div className={'container'}>
<div className={styles.inner}>
<span className={styles.message}>
⚠️ This is the archived documentation for k6 <b>{version}</b>.
{typeof versions[LATEST_VERSION] !== 'undefined' && (
<span>
{' '}
Go to the{' '}
<a
href="https://grafana.com/docs/k6/latest/"
target="_blank"
rel="noreferrer"
>
latest version
</a>
.
</span>
)}
⚠️ This documentation is outdated. Please visit grafana.com for the{' '}
<a href={canonicalUrl || 'https://grafana.com/docs/k6/latest/'}>
latest k6 documentation
</a>
.📚
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.wrapper {
margin: 140px 0 -145px 0;
//margin: 140px 0 -145px 0;
margin: 100px 0 -145px 0;

@include sm-down {
display: flex;
Expand Down
6 changes: 4 additions & 2 deletions src/components/templates/doc-page/doc-page.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.container {
margin-top: 100px;
//margin-top: 100px;
margin-top: 165px;
position: relative;
@include xl-down {
margin-top: 185px;
}
@include sm-down {
margin-top: 250px;
//margin-top: 250px;
margin-top: 240px;
width: 540px;
margin-left: auto;
margin-right: auto;
Expand Down
11 changes: 9 additions & 2 deletions src/layouts/doc-layout/doc-layout.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const DocLayout = ({
sidebarTree,
navLinks: links,
children,
canonicalUrl,
pageVersions = {},
sectionName = null,
path,
Expand Down Expand Up @@ -308,7 +309,9 @@ export const DocLayout = ({

if (sidebarRef && sidebarRef.current && sidebarScrollValue) {
setTimeout(() => {
sidebarRef.current.scrollTop = parseInt(sidebarScrollValue, 10);
if (sidebarRef && sidebarRef.current && sidebarScrollValue) {
sidebarRef.current.scrollTop = parseInt(sidebarScrollValue, 10);
}
}, 0);
}
}, [sidebarRef]);
Expand Down Expand Up @@ -419,7 +422,11 @@ export const DocLayout = ({
</div>
</div>
</Header>
{version && <VersionBanner version={version} versions={pageVersions} />}
<VersionBanner
canonicalUrl={canonicalUrl}
version={version}
versions={pageVersions}
/>

{children}
<MobileNav
Expand Down
1 change: 1 addition & 0 deletions src/templates/doc-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const DocPage = (props) => {
pageVersions={pageVersions}
path={path}
sectionName={sectionName}
canonicalUrl={frontmatter.canonicalUrl}
>
<div
className={classNames(
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/bundle-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const BundleBuilderPage = ({ pageContext: { sidebarTree, navLinks } }) => {
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Extensions"
canonicalUrl={SeoMetaData['bundle-builder'].data.canonicalUrl}
>
<ExtensionsTitleGroup
title={'Bundle'}
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Cloud = ({ pageContext: { sidebarTree, navLinks } }) => {
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Cloud"
canonicalUrl={SeoMetaData.cloud.data.canonicalUrl}
>
<PageInfo title={'k6 Cloud documentation'} />
<div className={`${docPageContent.inner}`}>
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Examples = ({ pageContext: { sidebarTree, navLinks } }) => {
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Examples"
canonicalUrl={SeoMetaData.examples.data.canonicalUrl}
>
<PageInfo
title={'Examples & Tutorials'}
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/explore-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ExploreExtensionsPage = ({
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Extensions"
canonicalUrl={SeoMetaData['explore-extensions'].data.canonicalUrl}
>
<ExtensionsTitleGroup
title={'Explore'}
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Extensions = ({ pageContext: { sidebarTree, navLinks } }) => {
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Extensions"
canonicalUrl={SeoMetaData.extensions.data.canonicalUrl}
>
<PageInfo
title={'k6 Extensions'}
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/guides.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const GuidesContent = ({
locale={locale}
pageTranslations={guidesTranslations}
sectionName="Guides"
canonicalUrl={SeoMetaData.guides.data.canonicalUrl}
>
<PageInfo {...pageInfo[locale]} />
<div className={classNames(docPageContent.inner)}>
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ const Integrations = ({ pageContext: { sidebarTree, navLinks } }) => {
sidebarTree={sidebarTree}
navLinks={navLinks}
sectionName="Integrations"
canonicalUrl={SeoMetaData.integrations.data.canonicalUrl}
>
<PageInfo title={'Integrations & Tools'} description={''} />
<div className={`${docPageContent.inner} `}>
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/javascript-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const JavascriptAPI = ({
path="/javascript-api/"
pageVersions={pageVersions}
sectionName="k6 API"
canonicalUrl={SeoMetaData['javascript-api'].data.canonicalUrl}
>
<PageInfo
title={'k6 API'}
Expand Down
1 change: 1 addition & 0 deletions src/templates/docs/versioned-javascript-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const VersionedJavascriptAPI = ({
path="/javascript-api/"
pageVersions={pageVersions}
sectionName="Javascript API"
canonicalUrl={SeoMetaData['javascript-api'].data.canonicalUrl}
>
<PageInfo
title={'JavaScript API'}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/seo-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default {
'bundle-builder': {
data: {
title: 'k6 Bundle Builder',
canonicalUrl: 'https://grafana.com/docs/k6/latest/extensions/explore/',
description:
'Easily create your own bespoke k6 binary with all the extensions you want to run using the bundle builder and xk6.',
},
Expand Down Expand Up @@ -69,6 +70,7 @@ export default {
data: {
title:
'Documentación de k6 - Herramienta Open Source de Pruebas de Carga',
canonicalUrl: 'https://grafana.com/docs/k6/latest/',
description:
'La documentación de k6 le ayudará a ejecutar sus pruebas de rendimiento correctamente. Aprenda y comience rápidamente a efectuar sus tests de carga y rendimiento',
},
Expand Down

0 comments on commit 26ee96a

Please sign in to comment.