mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 18:46:57 +02:00
feat(v2): shorter chunk naming for pages (#1688)
* refactor(v2): dont show absolute path for pages chunk/source naming * test n changelog
This commit is contained in:
parent
f1a504e813
commit
6287739bec
3 changed files with 10 additions and 5 deletions
|
@ -22,15 +22,15 @@ describe('docusaurus-plugin-content-pages', () => {
|
|||
siteConfig,
|
||||
});
|
||||
const pagesMetadatas = await plugin.loadContent();
|
||||
const pagesDir = plugin.contentPath;
|
||||
const pagesPath = path.relative(siteDir, plugin.contentPath);
|
||||
expect(pagesMetadatas).toEqual([
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
source: path.join('@site', pagesPath, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
source: path.join('@site', pagesPath, 'hello', 'world.js'),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ module.exports = function(context, opts) {
|
|||
|
||||
async loadContent() {
|
||||
const {include} = options;
|
||||
const {siteConfig} = context;
|
||||
const {siteConfig, siteDir} = context;
|
||||
const pagesDir = contentPath;
|
||||
|
||||
if (!fs.existsSync(pagesDir)) {
|
||||
|
@ -47,11 +47,15 @@ module.exports = function(context, opts) {
|
|||
|
||||
return pagesFiles.map(relativeSource => {
|
||||
const source = path.join(pagesDir, relativeSource);
|
||||
const aliasedSource = path.join(
|
||||
'@site',
|
||||
path.relative(siteDir, source),
|
||||
);
|
||||
const pathName = encodePath(fileToPath(relativeSource));
|
||||
// Default Language.
|
||||
return {
|
||||
permalink: pathName.replace(/^\//, baseUrl),
|
||||
source,
|
||||
source: aliasedSource,
|
||||
};
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue