forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make next export respect experimental.exportTrailingSlash (vercel#6752)
* Add --no-subfolders argument to next export * Use experimental.exportTrailingSlash instead of a cli flag * Add experimental.exportTrailingSlash documentation * Add tests for export with experimental.exportTrailingSlash * Remove docs * Remove comment
- Loading branch information
1 parent
87f60f5
commit be4026f
Showing
8 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
exportTrailingSlash: false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => ( | ||
<p>I am an about page</p> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => ( | ||
<p>I am a home page</p> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => ( | ||
<p>I am a list of posts</p> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => ( | ||
<p>I am a single post</p> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import fs from 'fs' | ||
import { join } from 'path' | ||
import cheerio from 'cheerio' | ||
import { promisify } from 'util' | ||
import { | ||
nextBuild, | ||
nextExport | ||
} from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5 | ||
const readFile = promisify(fs.readFile) | ||
const access = promisify(fs.access) | ||
const appDir = join(__dirname, '../') | ||
const outdir = join(appDir, 'out') | ||
|
||
describe('Export experimental.exportTrailingSlash set to false', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
await nextExport(appDir, { outdir }) | ||
}) | ||
|
||
it('should export pages as [filename].html instead of [filename]/index.html', async () => { | ||
expect.assertions(6) | ||
|
||
await expect(access(join(outdir, 'index.html'))).resolves.toBe(undefined) | ||
await expect(access(join(outdir, 'about.html'))).resolves.toBe(undefined) | ||
await expect(access(join(outdir, 'posts.html'))).resolves.toBe(undefined) | ||
await expect(access(join(outdir, 'posts', 'single.html'))).resolves.toBe(undefined) | ||
|
||
const html = await readFile(join(outdir, 'index.html')) | ||
const $ = cheerio.load(html) | ||
expect($('p').text()).toBe('I am a home page') | ||
|
||
const htmlSingle = await readFile(join(outdir, 'posts', 'single.html')) | ||
const $single = cheerio.load(htmlSingle) | ||
expect($single('p').text()).toBe('I am a single post') | ||
}) | ||
}) |