Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-scissors-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@patternfly/pfe-tools": patch
---

Removes special characters from component slugs ie. `special (characters)` becomes `special-characters`
2 changes: 1 addition & 1 deletion tools/pfe-tools/11ty/DocsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class DocsPage implements DocsPageRenderer {
private options?: DocsPageOptions) {
this.tagName = options?.tagName ?? '';
this.title = options?.title ?? Manifest.prettyTag(this.tagName);
this.slug = slugify(options?.aliases?.[this.tagName] ?? this.tagName.replace(/^\w+-/, '')).toLowerCase();
this.slug = slugify(options?.aliases?.[this.tagName] ?? this.tagName.replace(/^\w+-/, ''), { strict: true, lower: true });
this.summary = this.manifest.getSummary(this.tagName);
this.description = this.manifest.getDescription(this.tagName);
this.templates = nunjucks.configure(DocsPage.#templatesDir);
Expand Down
5 changes: 4 additions & 1 deletion tools/pfe-tools/custom-elements-manifest/lib/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { join } from 'node:path';
import { readFileSync } from 'node:fs';

import { getAllPackages } from './get-all-packages.js';
import slugify from 'slugify';
import { deslugify } from '@patternfly/pfe-tools/config.js';

type PredicateFn = (x: unknown) => boolean;
Expand Down Expand Up @@ -266,7 +267,9 @@ export class Manifest {
const { prettyTag } = Manifest;
return this.getDemos(tagName).map(demo => {
const permalink = demo.url.replace(options.demoURLPrefix, '/');
const [, slug = ''] = permalink.match(/\/components\/(.*)\/demo/) ?? [];
let [, slug = ''] = permalink.match(/\/components\/(.*)\/demo/) ?? [];
// strict removes all special characters from slug
slug = slugify(slug, { strict: true, lower: true });
const primaryElementName = deslugify(slug, options.rootDir);
const filePath = demo.source?.href.replace(options.sourceControlURLPrefix, `${options.rootDir}/`) ?? '';
const [last = ''] = filePath.split('/').reverse();
Expand Down