refactor: move rendering to util
This commit is contained in:
parent
fd432e6752
commit
c1ca780e20
6 changed files with 79 additions and 27 deletions
|
@ -1,15 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "md",
|
"name": "@performance/md",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "astro build --perf"
|
"build": "astro build --perf"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "unlicensed",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@performance/utils": "^0.0.0",
|
||||||
"astro": "^2.0.12"
|
"astro": "^2.0.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,8 @@
|
||||||
---
|
---
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from 'astro:content';
|
||||||
|
import { RenderContent } from '@performance/utils';
|
||||||
|
|
||||||
const posts = await getCollection('posts');
|
const posts = await getCollection('generated');
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<RenderContent {posts} />
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Md render test</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{
|
|
||||||
posts.map(async (entry) => {
|
|
||||||
const { Content } = await entry.render();
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>{entry.data.title}</h1>
|
|
||||||
<p>{entry.data.description}</p>
|
|
||||||
<Content />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
type Props = {
|
||||||
|
posts: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { posts } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Md render test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{
|
||||||
|
posts.map(async (entry) => {
|
||||||
|
const { Content } = await entry.render();
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>{entry.data.title}</h1>
|
||||||
|
<p>{entry.data.description}</p>
|
||||||
|
<Content />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</body>
|
||||||
|
</html>
|
2
packages/astro/performance/fixtures/utils/index.ts
Normal file
2
packages/astro/performance/fixtures/utils/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// @ts-ignore
|
||||||
|
export { default as RenderContent } from './RenderContent.astro';
|
17
packages/astro/performance/fixtures/utils/package.json
Normal file
17
packages/astro/performance/fixtures/utils/package.json
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "@performance/utils",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "unlicensed",
|
||||||
|
"devDependencies": {
|
||||||
|
"astro": "^2.0.12"
|
||||||
|
},
|
||||||
|
"exports": {
|
||||||
|
".": "./index.ts"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1106,10 +1106,31 @@ importers:
|
||||||
astro: link:../../..
|
astro: link:../../..
|
||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
|
|
||||||
|
packages/astro/performance:
|
||||||
|
specifiers: {}
|
||||||
|
|
||||||
packages/astro/performance/fixtures/md:
|
packages/astro/performance/fixtures/md:
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@performance/utils': ^0.0.0
|
||||||
astro: ^2.0.12
|
astro: ^2.0.12
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@performance/utils': link:../utils
|
||||||
|
astro: link:../../..
|
||||||
|
|
||||||
|
packages/astro/performance/fixtures/mdx:
|
||||||
|
specifiers:
|
||||||
|
'@astrojs/mdx': ^0.16.2
|
||||||
|
'@performance/utils': ^0.0.0
|
||||||
|
astro: ^2.0.12
|
||||||
|
dependencies:
|
||||||
|
'@astrojs/mdx': link:../../../../integrations/mdx
|
||||||
|
'@performance/utils': link:../utils
|
||||||
|
astro: link:../../..
|
||||||
|
|
||||||
|
packages/astro/performance/fixtures/utils:
|
||||||
|
specifiers:
|
||||||
|
astro: ^2.0.12
|
||||||
|
devDependencies:
|
||||||
astro: link:../../..
|
astro: link:../../..
|
||||||
|
|
||||||
packages/astro/test/benchmark/simple:
|
packages/astro/test/benchmark/simple:
|
||||||
|
|
Loading…
Reference in a new issue