diff --git a/docs/_plugins/rhds.ts b/docs/_plugins/rhds.ts index ce85cb4531..067b224e87 100644 --- a/docs/_plugins/rhds.ts +++ b/docs/_plugins/rhds.ts @@ -1,10 +1,9 @@ /// 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'; @@ -12,7 +11,6 @@ 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'; @@ -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); @@ -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 }); @@ -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); @@ -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); @@ -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(); }); @@ -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); } diff --git a/docs/_plugins/shortcodes.js b/docs/_plugins/shortcodes.js deleted file mode 100644 index 005546c8b3..0000000000 --- a/docs/_plugins/shortcodes.js +++ /dev/null @@ -1,7 +0,0 @@ -import { RepoStatusList, RepoStatusChecklist, RepoStatusTable } from './shortcodes/repoStatus.js'; - -export default function(eleventyConfig) { - eleventyConfig.addPlugin(RepoStatusList); - eleventyConfig.addPlugin(RepoStatusChecklist); - eleventyConfig.addPlugin(RepoStatusTable); -}; diff --git a/docs/_plugins/shortcodes/repoStatus.js b/docs/_plugins/shortcodes/repoStatus.js deleted file mode 100644 index 48b6a6fe69..0000000000 --- a/docs/_plugins/shortcodes/repoStatus.js +++ /dev/null @@ -1,18 +0,0 @@ - -export function RepoStatusList(eleventyConfig) { - eleventyConfig.addShortcode('repoStatusList', function repoStatusList() { - return ''; - }); -} - -export function RepoStatusChecklist(eleventyConfig) { - eleventyConfig.addShortcode('repoStatusChecklist', function repoStatusChecklist() { - return ''; - }); -} - -export function RepoStatusTable(eleventyConfig) { - eleventyConfig.addShortcode('repoStatusTable', function repoStatusTable() { - return ''; - }); -} diff --git a/eleventy.config.ts b/eleventy.config.ts index ce26084610..199438dfcb 100644 --- a/eleventy.config.ts +++ b/eleventy.config.ts @@ -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 }) { @@ -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',