diff --git a/cypress/components/Headlines.cy.tsx b/cypress/components/Headlines.cy.tsx index 2fd627b5d..76b806b4a 100644 --- a/cypress/components/Headlines.cy.tsx +++ b/cypress/components/Headlines.cy.tsx @@ -6,6 +6,7 @@ import { Headline4, } from '~/components/Headlines'; import mockNextRouter, { MockRouter } from '../plugins/mockNextRouterUtils'; +import slugifyMarkdownHeadline from '~/lib/slugifyMarkdownHeadline'; describe('Headlines Component', () => { let mockRouter: MockRouter; @@ -94,11 +95,13 @@ describe('Headlines Component', () => { it('should be active if the URL has the hash', () => { /* Testing the active headline with Headline1 */ + const title = 'What is JSON Schema?'; + const slug = slugifyMarkdownHeadline(title); // Set the URL with the hash - mockRouter.asPath = '/#what-is-json-schema'; + mockRouter.asPath = `/#${slug}`; // Check if Correct headline is active - cy.mount(What is JSON Schema?); + cy.mount({title}); cy.get('span').should( 'have.class', 'text-startBlue dark:text-endBlue inline-block ml-2', diff --git a/lib/slugifyMarkdownHeadline.ts b/lib/slugifyMarkdownHeadline.ts index ae943e138..d67c47e3c 100644 --- a/lib/slugifyMarkdownHeadline.ts +++ b/lib/slugifyMarkdownHeadline.ts @@ -6,7 +6,11 @@ export default function slugifyMarkdownHeadline( const FRAGMENT_REGEX = /\[#(?(\w|-|_)*)\]/g; if (!markdownChildren) return ''; if (typeof markdownChildren === 'string') - return slugify(markdownChildren, { lower: true, trim: true }); + return slugify(markdownChildren, { + lower: true, + trim: true, + remove: /[*+~()'"!]/g, + }); const metaSlug = markdownChildren.reduce((acc, child) => { if (acc) return acc; if (typeof child !== 'string') return null; @@ -21,6 +25,10 @@ export default function slugifyMarkdownHeadline( .filter((child) => typeof child === 'string') .map((string) => string.replace(FRAGMENT_REGEX, '')) .join(' '); - const slug = slugify(joinedChildren, { lower: true, trim: true }); + const slug = slugify(joinedChildren, { + lower: true, + trim: true, + remove: /[*+~()'"!]/g, + }); return slug; } diff --git a/pages/community/index.page.tsx b/pages/community/index.page.tsx index d68d6deb8..76c255895 100644 --- a/pages/community/index.page.tsx +++ b/pages/community/index.page.tsx @@ -149,10 +149,10 @@ export default function communityPages(props: any) {
-
-
+
+
-

+

Ambassadors Program

@@ -174,16 +174,16 @@ export default function communityPages(props: any) {

-
+
-
-
+
+
-

+

Join the JSON Schema Slack workspace!

@@ -201,7 +201,7 @@ export default function communityPages(props: any) {

-
+