Skip to content

Commit 641c7e5

Browse files
committed
feat: add pathPrefix option for subfolder deployment
1 parent f9ae2b8 commit 641c7e5

File tree

8 files changed

+44
-21
lines changed

8 files changed

+44
-21
lines changed

Diff for: .changeset/wet-waves-wait.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket/cli': patch
3+
---
4+
5+
Add a pathPrefix option to allow deployment to a subdirectory

Diff for: docs/docs/configuration/overview.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ import { rocketLaunch } from '@rocket/launch';
99

1010
export default {
1111
presets: [rocketLaunch()],
12-
build: {
13-
emptyOutputDir: true,
14-
pathPrefix: 'subfolder-only-for-build',
15-
serviceWorkerFileName: 'service-worker.js',
16-
},
12+
emptyOutputDir: true,
13+
pathPrefix: 'subfolder-only-for-build',
1714
};
1815
```
1916

Diff for: docs/guides/configuration/getting-started.md

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { absoluteBaseUrlNetlify } from '@rocket/core/helpers';
1212

1313
export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({
1414
presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
15-
emptyOutputDir: false,
1615
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
1716
});
1817
```

Diff for: packages/cli/src/RocketStart.js

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import { metaConfigToWebDevServerConfig } from 'plugins-manager';
99
export class RocketStart {
1010
commands = ['start'];
1111

12+
/**
13+
* @param {RocketCliOptions} config
14+
*/
15+
setupCommand(config) {
16+
delete config.pathPrefix;
17+
return config;
18+
}
19+
1220
/**
1321
* @param {object} options
1422
* @param {RocketCliOptions} options.config

Diff for: packages/cli/test-node/RocketCli.e2e.test.js

+21-13
Original file line numberDiff line numberDiff line change
@@ -203,35 +203,43 @@ describe('RocketCli e2e', () => {
203203
);
204204
});
205205

206-
it.skip('can add a pathprefix for the build output', async () => {
206+
it('can add a pathprefix that will not influence the start command', async () => {
207207
cli = new RocketCli({
208208
argv: [
209-
'build',
209+
'start',
210210
'--config-file',
211-
path.join(__dirname, 'e2e-fixtures', 'content', 'eleventy.rocket.config.js'),
211+
path.join(__dirname, 'e2e-fixtures', 'content', 'pathprefix.rocket.config.js'),
212212
],
213213
});
214214
await execute();
215215

216-
// const indexHtml = await readOutput('index.html', {
217-
// type: 'start',
218-
// });
219-
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>");
216+
const indexHtml = await readOutput('link/index.html', {
217+
type: 'start',
218+
});
219+
expect(indexHtml).to.equal(
220+
['<p><a href="../../">home</a></p>', '<p><a href="/">absolute home</a></p>'].join('\n'),
221+
);
220222
});
221223

222-
it.skip('works with an empty object in rocket.config.js', async () => {
224+
it('can add a pathPrefix that will be used in the build command', async () => {
223225
cli = new RocketCli({
224226
argv: [
225227
'build',
226228
'--config-file',
227-
path.join(__dirname, 'e2e-fixtures', 'content', 'empty.rocket.config.js'),
229+
path.join(__dirname, 'e2e-fixtures', 'content', 'pathPrefix.rocket.config.js'),
228230
],
229231
});
230232
await execute();
231233

232-
// const indexHtml = await readOutput('index.html', {
233-
// type: 'start',
234-
// });
235-
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>");
234+
const indexHtml = await readOutput('link/index.html', {
235+
stripServiceWorker: true,
236+
stripToBody: true,
237+
});
238+
expect(indexHtml).to.equal(
239+
[
240+
'<p><a href="../../">home</a></p>',
241+
'<p><a href="/my-sub-folder/">absolute home</a></p>',
242+
].join('\n'),
243+
);
236244
});
237245
});
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
---
2+
layout: layout.njk
3+
---
4+
15
[home](../index.md)
6+
7+
<a href="{{ '/' | url }}">absolute home</a>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
22
const config = {
3-
pathPrefix: 'my-sub-folder',
3+
pathPrefix: '/my-sub-folder/',
44
};
55

66
export default config;

Diff for: packages/eleventy-plugin-mdjs-unified/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"mdjs"
3232
],
3333
"dependencies": {
34-
"@mdjs/core": "^0.6.0",
34+
"@mdjs/core": "^0.6.1",
3535
"es-module-lexer": "^0.3.26",
3636
"unist-util-visit": "^2.0.3"
3737
},

0 commit comments

Comments
 (0)