Skip to content

Commit cd04ae8

Browse files
committed
feat(tools): add pfe assets 11ty plugin to pfe-tools
1 parent a5c9ee1 commit cd04ae8

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

.changeset/sharp-months-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/pfe-tools": minor
3+
---
4+
5+
Adds 11ty plugins to pfe-tools

.eleventy.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const anchorsPlugin = require('@orchidjs/eleventy-plugin-ids');
33
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
44
const directoryOutputPlugin = require('@11ty/eleventy-plugin-directory-output');
55

6-
const pfeAssetsPlugin = require('./docs/_plugins/pfe-assets.cjs');
6+
const pfeAssetsPlugin = require('@patternfly/pfe-tools/11ty/plugins/pfe-assets.cjs');
77

88
const customElementsManifestPlugin = require('@patternfly/pfe-tools/11ty/plugins/custom-elements-manifest.cjs');
99
const orderTagsPlugin = require('@patternfly/pfe-tools/11ty/plugins/order-tags.cjs');

docs/_plugins/types.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/pfe-tools/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
*.js
33
*.js.map
44

5+
!11ty/types.d.ts
56
!custom-elements-manifest/declaration.d.ts
67
!_scripts/dev.js

docs/_plugins/pfe-assets.cjs renamed to tools/pfe-tools/11ty/plugins/pfe-assets.cjs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
const fs = require('fs');
2-
const { join } = require('path');
2+
const path = require('path');
3+
4+
function exists(x) {
5+
try {
6+
fs.statSync(x);
7+
return true;
8+
} catch {
9+
return false;
10+
}
11+
}
312

413
/** Generate a map of files per package which should be copied to the site dir */
514
function getFilesToCopy() {
6-
const repoRoot = join(__dirname, '..', '..');
15+
/** best guess at abs-path to repo root */
16+
const repoRoot = path.join(__dirname, '..', '..', '..', '..').replace(/node_modules\/$/, '');
717

818
// Copy all component and core files to _site
9-
const files = Object.fromEntries([
10-
...fs.readdirSync(join(repoRoot, 'elements')).map(dir => [
11-
`elements/${dir}`,
12-
`components/${dir.replace('pfe-', '')}`,
13-
]),
14-
...fs.readdirSync(join(repoRoot, 'core')).map(dir => [
19+
const files = Object.fromEntries(fs.readdirSync(path.join(repoRoot, 'elements')).map(dir => [
20+
`elements/${dir}`,
21+
`components/${dir.replace('pfe-', '')}`,
22+
]));
23+
24+
if (exists(path.join(repoRoot, 'core'))) {
25+
Object.assign(files, Object.fromEntries(fs.readdirSync(path.join(repoRoot, 'core')).map(dir => [
1526
`core/${dir}`,
1627
`core/${dir.replace('pfe-', '')}`,
17-
]),
18-
]);
28+
])));
29+
}
1930

2031
return files;
2132
}

0 commit comments

Comments
 (0)