Skip to content

Commit eb644e0

Browse files
committed
fix(tools): windows paths
1 parent 25fe6fb commit eb644e0

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

docs/components/demos.11tydata.cjs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
const { dirname } = require('path');
21
module.exports = {
32
templateEngineOverride: 'njk',
43
permalink: '{{ demo.permalink }}',
54
pagination: {
65
data: 'demos',
76
alias: 'demo',
87
size: 1,
9-
// somehow the main pf-icon demo is being printed twice.
10-
// so we'll group by tag name, and only take the first of each.
11-
before: demos => Object.values(Object.groupBy(demos
12-
.filter(demo => demo.permalink?.includes(demo.tagName))
13-
.map(demo => {
14-
if (demo.filePath?.endsWith(`${demo.tagName}.html`)) {
15-
return {
16-
...demo,
17-
permalink: `${dirname(demo.permalink)}/`,
18-
};
19-
} else {
20-
return demo;
21-
}
22-
}), demo => demo.tagName)).map(([x]) => x),
238
},
249
};

tools/pfe-tools/11ty/plugins/custom-elements-manifest.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
const { join } = require('node:path');
2+
const { join, sep } = require('node:path');
33
const { existsSync } = require('node:fs');
44
const { glob } = require('glob');
55
const { stat, rm } = require('node:fs/promises');
@@ -63,7 +63,7 @@ module.exports = function configFunction(eleventyConfig, pluginOpts = {}) {
6363
const options = { ...getPfeConfig(), ...pluginOpts };
6464
if (runMode === 'build') {
6565
const files = await glob(`${dir.output}/${options.site.componentSubpath}/*/demo/*`);
66-
const htmls = files.filter(x => x.endsWith('.html') && !x.endsWith('/index.html'));
66+
const htmls = files.filter(x => x.endsWith('.html') && !x.endsWith(`${sep}index.html`));
6767
for (const file of htmls) {
6868
const dir = file.replace(/\.html$/, '');
6969
if (await isDir(dir)) {
@@ -77,7 +77,7 @@ module.exports = function configFunction(eleventyConfig, pluginOpts = {}) {
7777
// components/jazz-hands/demo/special-name/index.html
7878
// Here, we rewrite the subresource links so they point to the right files.
7979
eleventyConfig.addTransform('reroute-special-demo-subresources', function(content) {
80-
if (this.inputPath.endsWith('/demos.html')) {
80+
if (this.inputPath.endsWith(`${sep}demos.html`)) {
8181
const [, one, , three, four] = this.outputPath.split('/');
8282
if (one === 'components' && three === 'demo' && four !== 'index.html') {
8383
const cheerio = require('cheerio');

tools/pfe-tools/custom-elements-manifest/lib/Manifest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
Slot,
1717
} from 'custom-elements-manifest/schema';
1818

19-
import { join, normalize } from 'node:path';
19+
import path, { join, normalize } from 'node:path';
2020
import { readFileSync } from 'node:fs';
2121

2222
import { getAllPackages } from './get-all-packages.js';
@@ -317,7 +317,7 @@ export class Manifest {
317317
const filePath =
318318
demo.source?.href.replace(
319319
options.sourceControlURLPrefix,
320-
`${join(options.rootDir, options.elementsDir)}/`,
320+
`${join(normalize(options.rootDir), normalize(options.elementsDir))}${path.sep}`,
321321
) ?? '';
322322
const [last = ''] = filePath.split('/').reverse();
323323
const filename = last.replace('.html', '');

tools/pfe-tools/dev-server/plugins/dev-server-templates.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DemoRecord } from '../../custom-elements-manifest/lib/Manifest.js'
33
import type { Context, Next } from 'koa';
44

55
import { readFile } from 'node:fs/promises';
6-
import { dirname, join } from 'node:path';
6+
import path, { dirname, join } from 'node:path';
77
import { fileURLToPath } from 'node:url';
88

99
import nunjucks from 'nunjucks';
@@ -39,8 +39,7 @@ async function getDemos(config: PfeDevServerInternalConfig) {
3939
manifest.getDemoMetadata(tagName, config as PfeDevServerInternalConfig)
4040
.filter(demo => demo.filePath?.includes(tagName))
4141
.map(demo => {
42-
if (demo.filePath?.endsWith(`${tagName}.html`)
43-
|| demo.filePath?.endsWith('/index.html')) {
42+
if (demo.filePath?.endsWith(`${path.sep}index.html`)) {
4443
return {
4544
...demo,
4645
permalink: `${dirname(demo.permalink)}/`,

0 commit comments

Comments
 (0)