Compare commits

...

2 Commits

Author SHA1 Message Date
github-actions[bot]
fd4bc27f16 Version Packages 2021-01-06 00:49:41 +01:00
Thomas Allmer
641c7e551c feat: add pathPrefix option for subfolder deployment 2021-01-06 00:46:39 +01:00
9 changed files with 46 additions and 22 deletions

View File

@@ -9,11 +9,8 @@ import { rocketLaunch } from '@rocket/launch';
export default { export default {
presets: [rocketLaunch()], presets: [rocketLaunch()],
build: { emptyOutputDir: true,
emptyOutputDir: true, pathPrefix: 'subfolder-only-for-build',
pathPrefix: 'subfolder-only-for-build',
serviceWorkerFileName: 'service-worker.js',
},
}; };
``` ```

View File

@@ -12,7 +12,6 @@ import { absoluteBaseUrlNetlify } from '@rocket/core/helpers';
export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({ export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({
presets: [rocketLaunch(), rocketBlog(), rocketSearch()], presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
emptyOutputDir: false,
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'), absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
}); });
``` ```

View File

@@ -1,5 +1,11 @@
# @rocket/cli # @rocket/cli
## 0.1.2
### Patch Changes
- 641c7e5: Add a pathPrefix option to allow deployment to a subdirectory
## 0.1.1 ## 0.1.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/cli", "name": "@rocket/cli",
"version": "0.1.1", "version": "0.1.2",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },

View File

@@ -9,6 +9,14 @@ import { metaConfigToWebDevServerConfig } from 'plugins-manager';
export class RocketStart { export class RocketStart {
commands = ['start']; commands = ['start'];
/**
* @param {RocketCliOptions} config
*/
setupCommand(config) {
delete config.pathPrefix;
return config;
}
/** /**
* @param {object} options * @param {object} options
* @param {RocketCliOptions} options.config * @param {RocketCliOptions} options.config

View File

@@ -203,35 +203,43 @@ describe('RocketCli e2e', () => {
); );
}); });
it.skip('can add a pathprefix for the build output', async () => { it('can add a pathprefix that will not influence the start command', async () => {
cli = new RocketCli({ cli = new RocketCli({
argv: [ argv: [
'build', 'start',
'--config-file', '--config-file',
path.join(__dirname, 'e2e-fixtures', 'content', 'eleventy.rocket.config.js'), path.join(__dirname, 'e2e-fixtures', 'content', 'pathprefix.rocket.config.js'),
], ],
}); });
await execute(); await execute();
// const indexHtml = await readOutput('index.html', { const indexHtml = await readOutput('link/index.html', {
// type: 'start', type: 'start',
// }); });
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>"); expect(indexHtml).to.equal(
['<p><a href="../../">home</a></p>', '<p><a href="/">absolute home</a></p>'].join('\n'),
);
}); });
it.skip('works with an empty object in rocket.config.js', async () => { it('can add a pathPrefix that will be used in the build command', async () => {
cli = new RocketCli({ cli = new RocketCli({
argv: [ argv: [
'build', 'build',
'--config-file', '--config-file',
path.join(__dirname, 'e2e-fixtures', 'content', 'empty.rocket.config.js'), path.join(__dirname, 'e2e-fixtures', 'content', 'pathPrefix.rocket.config.js'),
], ],
}); });
await execute(); await execute();
// const indexHtml = await readOutput('index.html', { const indexHtml = await readOutput('link/index.html', {
// type: 'start', stripServiceWorker: true,
// }); stripToBody: true,
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>"); });
expect(indexHtml).to.equal(
[
'<p><a href="../../">home</a></p>',
'<p><a href="/my-sub-folder/">absolute home</a></p>',
].join('\n'),
);
}); });
}); });

View File

@@ -1 +1,7 @@
---
layout: layout.njk
---
[home](../index.md) [home](../index.md)
<a href="{{ '/' | url }}">absolute home</a>

View File

@@ -1,6 +1,6 @@
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */ /** @type {Partial<import("../../../types/main").RocketCliOptions>} */
const config = { const config = {
pathPrefix: 'my-sub-folder', pathPrefix: '/my-sub-folder/',
}; };
export default config; export default config;

View File

@@ -31,7 +31,7 @@
"mdjs" "mdjs"
], ],
"dependencies": { "dependencies": {
"@mdjs/core": "^0.6.0", "@mdjs/core": "^0.6.1",
"es-module-lexer": "^0.3.26", "es-module-lexer": "^0.3.26",
"unist-util-visit": "^2.0.3" "unist-util-visit": "^2.0.3"
}, },