mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 03:26:57 +02:00
perf(v2): smaller bundlesize by embedding metadata to content (#2088)
* wip embed metadata to content * embed metadata in blog as well * refactor * update test * yarn lock * avoid overwriting file everytime we run new nodejs process * nits
This commit is contained in:
parent
32c9d07b90
commit
7f8aca2ddc
16 changed files with 236 additions and 200 deletions
|
@ -10,7 +10,7 @@ import globby from 'globby';
|
|||
import path from 'path';
|
||||
import {Feed} from 'feed';
|
||||
import {PluginOptions, BlogPost, DateLink} from './types';
|
||||
import {parse, normalizeUrl} from '@docusaurus/utils';
|
||||
import {parse, normalizeUrl, aliasedSitePath} from '@docusaurus/utils';
|
||||
import {LoadContext} from '@docusaurus/types';
|
||||
|
||||
export function truncate(fileString: string, truncateMarker: RegExp | string) {
|
||||
|
@ -100,10 +100,8 @@ export async function generateBlogPosts(
|
|||
|
||||
await Promise.all(
|
||||
blogFiles.map(async (relativeSource: string) => {
|
||||
// Cannot use path.join() as it resolves '../' and removes the '@site'.
|
||||
// Let webpack loader resolve it.
|
||||
const source = path.join(blogDir, relativeSource);
|
||||
const aliasedSource = `@site/${path.relative(siteDir, source)}`;
|
||||
const aliasedSource = aliasedSitePath(source, siteDir);
|
||||
const blogFileName = path.basename(relativeSource);
|
||||
|
||||
const fileString = await fs.readFile(source, 'utf-8');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue