diff --git a/src/__fixtures__/page.tsx b/src/__fixtures__/page.tsx index 30ceada248..78042bd41c 100644 --- a/src/__fixtures__/page.tsx +++ b/src/__fixtures__/page.tsx @@ -1,6 +1,7 @@ import { MDXPage, SingleMDXPage, + SingleMDXDocPage, SiteMetaData } from '../types'; @@ -52,4 +53,32 @@ export const createSingleMDXData = (): { } } } -}); \ No newline at end of file +}); + +export const createMDXDocsData = (toc): { + mdx: SingleMDXDocPage; +} => ({ + mdx: { + id: 'mdx-1', + fields: { + slug: '/mdx/mdx-page-title', + }, + frontmatter: { + title: 'MDX Doc Page title', + authors: 'pmc, pmc2', + toc: toc ? true : false + }, + tableOfContents: { + items: [ + { + url: '#section1', + title: 'Section 1' + }, + { + url: '#section2', + title: 'Section 2' + } + ], + } + } +}); diff --git a/src/pages/__tests__/__snapshots__/supported-platforms.test.tsx.snap b/src/pages/__tests__/__snapshots__/supported-platforms.test.tsx.snap index 446a05d9ac..9ecab25145 100644 --- a/src/pages/__tests__/__snapshots__/supported-platforms.test.tsx.snap +++ b/src/pages/__tests__/__snapshots__/supported-platforms.test.tsx.snap @@ -926,6 +926,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -1924,6 +1926,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -2676,6 +2680,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -3087,6 +3093,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -3839,6 +3847,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -4549,6 +4559,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -4943,6 +4955,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -5242,6 +5256,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + @@ -5446,6 +5462,8 @@ exports[`Supported Platforms page > renders correctly 1`] = `

+ + diff --git a/src/pages/supported-platforms.tsx b/src/pages/supported-platforms.tsx index 984f9fd68c..7a6dc1b520 100644 --- a/src/pages/supported-platforms.tsx +++ b/src/pages/supported-platforms.tsx @@ -39,32 +39,31 @@ const SupportedPlatformsPage = () => { { versionsActive.map((version, index) => ( -

{version}

+ +

{version}

+ ))} - - { Object.keys(versions).map((os, index) => ( - <> - -

{os}

+ { Object.keys(versions).map((os) => ( + + +

{os}

+ + {Object.keys(versions[os]).map((platform) => ( + +

{platform}

+ { versionsActive.map((version, index) => ( + +

+ {validator(versions[os][platform], version)} +

+ + ))} - {Object.keys(versions[os]).map((platform, index) => ( - -

{platform}

- { versionsActive.map((version, index) => ( - -

- {validator(versions[os][platform], version)} -

- - ))} - - ))} - - - ))} - + ))} + + ))}

1. These builds should work on any distribution with glibc version 2.12 or higher.

diff --git a/src/templates/__tests__/__snapshots__/blogPost.test.tsx.snap b/src/templates/__tests__/__snapshots__/blogPost.test.tsx.snap index 9e74ff2f13..48531c0e7d 100644 --- a/src/templates/__tests__/__snapshots__/blogPost.test.tsx.snap +++ b/src/templates/__tests__/__snapshots__/blogPost.test.tsx.snap @@ -1,27 +1,5 @@ // Vitest Snapshot v1 -exports[`BlogPost Template page > formatDiv renders correctly - inline code block 1`] = ` -
- - - test - - -
-`; - -exports[`BlogPost Template page > formatDiv renders correctly 1`] = ` -
-
-

- test -

-
-
-`; - exports[`BlogPost Template page > renders correctly - featured image 1`] = `
installation renders correctly 1`] = ` +
+
+
+
+
+

+ MDX Doc Page title +

+
+
+
+
+
+
+
+
+
+
+
+ bash +
+
+
    + + + +
+
+
+
+                      
+ + + # Install the latest version + +
+ + $ + + + winget install + + EclipseAdoptium.Temurin.17.JDK +
+
+
+
+                      
+ + + # Install a different version + +
+ + $ + + + winget install + + EclipseAdoptium.Temurin.11.JDK +
+
+
+
+                      
+ + + # Upgrade the Winget package + +
+ + $ + + + winget upgrade + + EclipseAdoptium.Temurin.17.JDK +
+
+
+
+                      
+ + + # Uninstall the Winget package + +
+ + $ + + + winget uninstall + + EclipseAdoptium.Temurin.17.JDK +
+
+ + Read documentation + +
+
+
+
+
+
+
+
+ sample docs +
+
+ DOCUMENTATION AUTHORS + +
+
+ + Help us make these docs great! + +
+ + All Adoptium docs are open source. See something that's wrong or unclear? + +
+ + + + + Edit this page + +
+
+
+
+
+
+`; + +exports[`Docs Template page > renders correctly 1`] = ` +
+
+
+
+
+

+ MDX Doc Page title +

+ sample docs +
+
+ DOCUMENTATION AUTHORS + +
+
+ + Help us make these docs great! + +
+ + All Adoptium docs are open source. See something that's wrong or unclear? + +
+ + + + + Edit this page + +
+
+
+
+
+
+`; + +exports[`Docs Template page > toc renders correctly 1`] = ` +
+
+
+
+
+

+ MDX Doc Page title +

+
+ + Table of Contents + + +
+ sample docs +
+
+ DOCUMENTATION AUTHORS + +
+
+ + Help us make these docs great! + +
+ + All Adoptium docs are open source. See something that's wrong or unclear? + +
+ + + + + Edit this page + +
+
+
+
+
+
+`; diff --git a/src/templates/__tests__/blogPost.test.tsx b/src/templates/__tests__/blogPost.test.tsx index 36ca6da650..3acf3e0312 100644 --- a/src/templates/__tests__/blogPost.test.tsx +++ b/src/templates/__tests__/blogPost.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { render } from '@testing-library/react'; -import BlogPost, { Head, formatDiv } from '../../templates/blogPost'; +import BlogPost, { Head } from '../../templates/blogPost'; import { describe, expect, it } from 'vitest' import { axe } from 'vitest-axe'; import { createSingleMDXData } from '../../__fixtures__/page'; @@ -53,16 +53,6 @@ describe('BlogPost Template page', () => { expect(pageContent).toMatchSnapshot(); }); - it('formatDiv renders correctly', () => { - const { container } = render(formatDiv({ dangerouslySetInnerHTML: { __html: '

test

' } })); - expect(container).toMatchSnapshot(); - }); - - it('formatDiv renders correctly - inline code block', () => { - const { container } = render(formatDiv({ dangerouslySetInnerHTML: { __html: 'test' } })); - expect(container).toMatchSnapshot(); - }); - it('head renders correctly', () => { const { container } = render(); // eslint-disable-next-line diff --git a/src/templates/__tests__/docsPage.test.tsx b/src/templates/__tests__/docsPage.test.tsx new file mode 100644 index 0000000000..96754b2d77 --- /dev/null +++ b/src/templates/__tests__/docsPage.test.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import DocsPage, { Head } from '../docsPage'; +import { describe, expect, it } from 'vitest' +import { axe } from 'vitest-axe'; +import { createMDXDocsData } from '../../__fixtures__/page'; + +let mockData = createMDXDocsData(false); +const pageContext = { + relativePath: 'docs/sample/index.md', +} + +describe('Docs Template page', () => { + it('renders correctly', () => { + const { container } = render(); + // eslint-disable-next-line + const pageContent = container.querySelector('main'); + + expect(pageContent).toMatchSnapshot(); + }); + + it('installation renders correctly', () => { + mockData.mdx.fields.slug = '/installation/'; + const { container } = render(); + // eslint-disable-next-line + const pageContent = container.querySelector('main'); + + expect(pageContent).toMatchSnapshot(); + }); + + it('toc renders correctly', () => { + let mockData = createMDXDocsData(true); + const { container } = render(); + // eslint-disable-next-line + const pageContent = container.querySelector('main'); + + expect(pageContent).toMatchSnapshot(); + }); + + it('head renders correctly', () => { + const { container } = render(); + // eslint-disable-next-line + const title = container.querySelector('title'); + expect(title?.textContent).toEqual('MDX Doc Page title | Adoptium'); + }); + + it('has no accessibility violations', async () => { + const { container } = render(); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); +}); \ No newline at end of file diff --git a/src/templates/authorPage.tsx b/src/templates/authorPage.tsx index 3e959883d3..03e290459f 100644 --- a/src/templates/authorPage.tsx +++ b/src/templates/authorPage.tsx @@ -60,11 +60,6 @@ export const Head = ({ pageContext }) => { export const authorPageQuery = graphql` query authorPageQuery($author: String!, $limit: Int!, $language: String!) { - site { - siteMetadata { - title - } - } allMdx( filter: {frontmatter: {author: {eq: $author}}} sort: {frontmatter: {date: DESC}} diff --git a/src/templates/blogPage.tsx b/src/templates/blogPage.tsx index 2e02164094..4d06351f13 100644 --- a/src/templates/blogPage.tsx +++ b/src/templates/blogPage.tsx @@ -81,11 +81,6 @@ export const Head = ({ pageContext }) => { export const blogPageQuery = graphql` query blogPageQuery($skip: Int!, $limit: Int!, $language: String!) { - site { - siteMetadata { - title - } - } allMdx( filter: {internal: {contentFilePath: { regex: "/blog/" }}}, sort: {frontmatter: {date: DESC} diff --git a/src/templates/blogPost.tsx b/src/templates/blogPost.tsx index 170b023c01..e0fdabee5e 100644 --- a/src/templates/blogPost.tsx +++ b/src/templates/blogPost.tsx @@ -7,29 +7,11 @@ import Layout from '../components/Layout'; import Seo from '../components/Seo'; import BlogAuthor from '../components/BlogAuthor'; import AuthorData from '../json/authors.json'; -import GuestPost from '../components/GuestPost'; import Byline from '../components/Byline'; import ShareButton from '../components/Share'; import Tags from '../components/Tags'; import Comments from '../components/Comments'; - -export const formatDiv = props => { - // convert inline code to code blocks - if (props.dangerouslySetInnerHTML.__html.includes('class="language-text"')) { - return - } else { - return
; - } -} - -const components = { - GuestPost, - blockquote: props =>
, - table: props => , - thead: props => , - li: props =>
  • , - div: formatDiv -}; +import { mdxComponents } from '../util/mdxComponents'; const BlogPostTemplate = ({ data, pageContext, location, children }) => { const post = data.mdx; @@ -48,7 +30,7 @@ const BlogPostTemplate = ({ data, pageContext, location, children }) => { - + {children} diff --git a/src/templates/tagPage.tsx b/src/templates/tagPage.tsx index c678e92290..3e509912a8 100644 --- a/src/templates/tagPage.tsx +++ b/src/templates/tagPage.tsx @@ -53,11 +53,6 @@ export const Head = ({ pageContext }) => { export const tagsPageQuery = graphql` query tagsPageQuery($tag: String!, $language: String!) { - site { - siteMetadata { - title - } - } allMdx( filter: {frontmatter: {tags: {eq: $tag}}} sort: {frontmatter: {date: DESC}} diff --git a/src/types/index.tsx b/src/types/index.tsx index d551ca0b22..85b683c867 100644 --- a/src/types/index.tsx +++ b/src/types/index.tsx @@ -45,6 +45,25 @@ export interface SingleMDXPage { } } +export interface SingleMDXDocPage { + id: string; + fields: { + slug: string; + } + frontmatter: { + } + tableOfContents?: { + items: [ + tableOfContents[] + ] + } +} + +export interface tableOfContents { + title: string; + url: string; +} + export interface SiteMetaData { siteMetadata: { title: string; diff --git a/src/util/__tests__/__snapshots__/mdxComponents.test.tsx.snap b/src/util/__tests__/__snapshots__/mdxComponents.test.tsx.snap new file mode 100644 index 0000000000..042da5215f --- /dev/null +++ b/src/util/__tests__/__snapshots__/mdxComponents.test.tsx.snap @@ -0,0 +1,111 @@ +// Vitest Snapshot v1 + +exports[`mdxComponents > class renders correctly 1`] = ` +
    +
    + test +
    +
    +`; + +exports[`mdxComponents > collapsible renders correctly - with title 1`] = ` +
    +
    + + test + +
    + test +
    +
    +
    +`; + +exports[`mdxComponents > collapsible renders correctly 1`] = ` +
    +
    + test +
    +
    +`; + +exports[`mdxComponents > cross renders correctly 1`] = ` +
    + + + +
    +`; + +exports[`mdxComponents > formatDiv renders correctly - inline code block 1`] = ` +
    + + + test + + +
    +`; + +exports[`mdxComponents > formatDiv renders correctly 1`] = ` +
    +
    +

    + test +

    +
    +
    +`; + +exports[`mdxComponents > small renders correctly 1`] = ` +
    +
    + + test + +
    +`; + +exports[`mdxComponents > tick renders correctly 1`] = ` +
    + + + +
    +`; diff --git a/src/util/__tests__/mdxComponents.test.tsx b/src/util/__tests__/mdxComponents.test.tsx new file mode 100644 index 0000000000..c05f70a33c --- /dev/null +++ b/src/util/__tests__/mdxComponents.test.tsx @@ -0,0 +1,45 @@ +import { mdxComponents } from '../mdxComponents'; +import { render } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; + +describe('mdxComponents', () => { + it('formatDiv renders correctly', () => { + const { container } = render(mdxComponents.div({ dangerouslySetInnerHTML: { __html: '

    test

    ' } })); + expect(container).toMatchSnapshot(); + }); + + it('formatDiv renders correctly - inline code block', () => { + const { container } = render(mdxComponents.div({ dangerouslySetInnerHTML: { __html: 'test' } })); + expect(container).toMatchSnapshot(); + }); + + it('small renders correctly', () => { + const { container } = render(mdxComponents.Small({ children: 'test' })); + expect(container).toMatchSnapshot(); + }); + + it('tick renders correctly', () => { + const { container } = render(mdxComponents.Tick()); + expect(container).toMatchSnapshot(); + }); + + it('cross renders correctly', () => { + const { container } = render(mdxComponents.Cross()); + expect(container).toMatchSnapshot(); + }); + + it('collapsible renders correctly', () => { + const { container } = render(mdxComponents.Collapsible({ children: 'test' })); + expect(container).toMatchSnapshot(); + }); + + it('collapsible renders correctly - with title', () => { + const { container } = render(mdxComponents.Collapsible({ title: 'test', children: 'test' })); + expect(container).toMatchSnapshot(); + }); + + it('class renders correctly', () => { + const { container } = render(mdxComponents.Class({ name: 'test', children: 'test' })); + expect(container).toMatchSnapshot(); + }); +});