Skip to content

Commit

Permalink
docs: remove last vestiges of rhds shortcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Oct 14, 2024
1 parent e2e1a0d commit 24144ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 42 deletions.
24 changes: 9 additions & 15 deletions docs/_plugins/rhds.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/// <reference lib="ESNext.Array"/>

import * as ChildProcess from 'node:child_process';
import { readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { promisify } from 'node:util';
import { readFile, writeFile, mkdir } from 'node:fs/promises';
import { readdir, readFile, writeFile, mkdir } from 'node:fs/promises';
import { makeDemoEnv } from '../../scripts/environment.js';

import yaml from 'js-yaml';
import slugify from 'slugify';
import capitalize from 'capitalize';

import RHDSAlphabetizeTagsPlugin from './alphabetize-tags.js';
import RHDSShortcodesPlugin from './shortcodes.js';
import RHDSElementDocsPlugin from './element-docs.ts';
import RHDSElementDemosPlugin from './element-demos.js';

Expand Down Expand Up @@ -67,15 +65,13 @@ const COPY_CONTENT_EXTENSIONS = [
/**
* Generate a map of files per package which should be copied to the site dir
*/
function getFilesToCopy() {
async function getFilesToCopy() {
// Copy element demo files
const repoRoot = cwd;
const tagNames = readdirSync(join(repoRoot, 'elements'), { withFileTypes: true })
const tagNames = (await readdir(join(repoRoot, 'elements'), { withFileTypes: true }))
.filter(ent => ent.isDirectory())
.map(ent => ent.name);

const config = getPfeConfig();

// Copy all component and core files to _site
return Object.fromEntries(tagNames.flatMap(tagName => {
const slug = getTagNameSlug(tagName);
Expand All @@ -95,7 +91,7 @@ interface Options {
* @param opts
* @param opts.tagsToAlphabetize
*/
export default function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Options) {
export default async function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Options) {
eleventyConfig.on('eleventy.before', async ({ directories }) => {
const outPath = join(directories.output, 'assets/javascript/repoStatus.json');
await mkdir(dirname(outPath), { recursive: true });
Expand All @@ -120,11 +116,10 @@ export default function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Optio
await writeFile(outPath, await makeDemoEnv(), 'utf8');
});

eleventyConfig.addDataExtension('yml, yaml', contents => yaml.load(contents));
eleventyConfig.addDataExtension('yml, yaml', (contents: string) => yaml.load(contents));

eleventyConfig.addPlugin(RHDSAlphabetizeTagsPlugin, { tagsToAlphabetize });

eleventyConfig.addPlugin(RHDSShortcodesPlugin);
eleventyConfig.addPlugin(RHDSElementDocsPlugin);
eleventyConfig.addPlugin(RHDSElementDemosPlugin);

Expand All @@ -139,14 +134,13 @@ export default function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Optio
'node_modules/@patternfly/icons/': '/assets/packages/@patternfly/icons/',
});

const filesToCopy = getFilesToCopy();
eleventyConfig.addPassthroughCopy(filesToCopy, {
eleventyConfig.addPassthroughCopy(await getFilesToCopy(), {
filter: (path: string) => !path.endsWith('.html'),
});

eleventyConfig.addJavaScriptFunction('getTagNameSlug', getTagNameSlug);

eleventyConfig.addFilter('getPrettyElementName', function(tagName) {
eleventyConfig.addFilter('getPrettyElementName', function(tagName: string) {
const slug = getTagNameSlug(tagName);
const deslugify = eleventyConfig.getFilter('deslugify');
return pfeconfig.aliases[tagName] || deslugify(slug);
Expand All @@ -156,7 +150,7 @@ export default function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Optio
return capitalize(slug.replace(/-/g, ' '));
});

eleventyConfig.addFilter('makeSentenceCase', function(value) {
eleventyConfig.addFilter('makeSentenceCase', function(value: string) {
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
});

Expand Down Expand Up @@ -202,7 +196,7 @@ export default function(eleventyConfig: UserConfig, { tagsToAlphabetize }: Optio
eleventyConfig.addWatchTarget('docs/patterns/**/patterns/*.html');
eleventyConfig.addWatchTarget('docs/theming/**/patterns/*.html');

for (const tagName of readdirSync(join(cwd, './elements/'))) {
for (const tagName of await readdir(join(cwd, './elements/'))) {
const dir = join(cwd, './elements/', tagName, 'docs/');
eleventyConfig.addWatchTarget(dir);
}
Expand Down
7 changes: 0 additions & 7 deletions docs/_plugins/shortcodes.js

This file was deleted.

18 changes: 0 additions & 18 deletions docs/_plugins/shortcodes/repoStatus.js

This file was deleted.

4 changes: 2 additions & 2 deletions eleventy.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const isWatch =
const isLocal = !(process.env.CI || process.env.DEPLOY_URL);

/** @param eleventyConfig */
export default function(eleventyConfig: UserConfig) {
export default async function(eleventyConfig: UserConfig) {
eleventyConfig.setQuietMode(true);

eleventyConfig.on('eleventy.before', function({ runMode }) {
Expand Down Expand Up @@ -242,7 +242,7 @@ export default function(eleventyConfig: UserConfig) {
* Collections to organize by 'order' value in front matter, then alphabetical by title;
* instead of by date
*/
eleventyConfig.addPlugin(RHDSPlugin, {
await eleventyConfig.addPlugin(RHDSPlugin, {
tagsToAlphabetize: [
'component',
'foundations',
Expand Down

0 comments on commit 24144ee

Please sign in to comment.