Skip to content

Commit 42436e6

Browse files
Fix process docs
1 parent 346ae05 commit 42436e6

File tree

2 files changed

+50
-52
lines changed

2 files changed

+50
-52
lines changed

docs-src/index.js

+49-51
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,61 @@ const src = './docs-src/pages/';
1313
const dist = './docs/';
1414
const md = './docs-src/md';
1515

16-
const plugins = [
17-
components({
18-
root: './docs-src',
19-
folders: ['components', 'layouts'],
20-
strict: true,
21-
expressions: {
22-
locals: {
23-
title: 'PostHTML Components'
24-
}
25-
}
26-
}),
16+
const options = {};
2717

28-
markdownIt({
29-
root: md,
30-
plugins: [
31-
{
32-
plugin: anchor,
33-
options: {
34-
level: [1, 2, 3],
35-
permalink: anchor.permalink.linkInsideHeader({
36-
symbol: '#',
37-
placement: 'before'
38-
})
39-
}
40-
},
41-
{
42-
plugin: markdownItToc,
43-
options: {
44-
level: [1, 2, 3],
45-
containerClass: 'h-100 flex-column align-items-stretch ps-4 p-3 bg-white rounded-3 doc-shadow',
46-
containerId: 'header-toc',
47-
listClass: 'nav flex-column',
48-
itemClass: 'nav-item',
49-
linkClass: 'nav-link',
50-
listType: 'ul'
18+
readdirSync(src).forEach(file => {
19+
const html = readFileSync(path.resolve(`${src}${file}`), 'utf-8');
20+
21+
posthtml([
22+
components({
23+
root: './docs-src',
24+
folders: ['components', 'layouts'],
25+
strict: true,
26+
expressions: {
27+
locals: {
28+
title: 'PostHTML Components'
5129
}
5230
}
53-
]
54-
}),
55-
56-
beautify({
57-
rules: {
58-
indent: 2,
59-
blankLines: false,
60-
sortAttr: false
61-
}
62-
}),
31+
}),
6332

64-
processCodeTags()
65-
];
66-
67-
const options = {};
33+
markdownIt({
34+
root: md,
35+
plugins: [
36+
{
37+
plugin: anchor,
38+
options: {
39+
level: [1, 2, 3],
40+
permalink: anchor.permalink.linkInsideHeader({
41+
symbol: '#',
42+
placement: 'before'
43+
})
44+
}
45+
},
46+
{
47+
plugin: markdownItToc,
48+
options: {
49+
level: [1, 2, 3],
50+
containerClass: 'h-100 flex-column align-items-stretch ps-4 p-3 bg-white rounded-3 doc-shadow',
51+
containerId: 'header-toc',
52+
listClass: 'nav flex-column',
53+
itemClass: 'nav-item',
54+
linkClass: 'nav-link',
55+
listType: 'ul'
56+
}
57+
}
58+
]
59+
}),
6860

69-
readdirSync(src).forEach(file => {
70-
const html = readFileSync(path.resolve(`${src}${file}`), 'utf-8');
61+
beautify({
62+
rules: {
63+
indent: 2,
64+
blankLines: false,
65+
sortAttr: false
66+
}
67+
}),
7168

72-
posthtml(plugins)
69+
processCodeTags()
70+
])
7371
.process(html, options)
7472
.then(result => {
7573
writeFileSync(path.resolve(`${dist}${file}`), result.html, 'utf-8');

docs/test.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<h1 class="display-1 fw-bold mb-4">Playground</h1>
5050
<div class="wrapper">
5151
<div class="demo my-demo" computed:acomputed="true" something="alocal">
52-
{"title":"PostHTML Components","close":true,"$slots":{},"aStringOverride":"My override string changed","anObjectOverride":{"third":"Third override item","fourth":"Fourth override item"},"computed:aComputed":true,"class":"my-demo","anObjectMerged":{"third":"Third merged item","fourth":"Fourth merged item","anObjectMerged1":{"third":"Third merged item (UPDATED?)","fourth1":"Fourth merged item"}},"post":{"title":"My post title","body":"My post body","comments":[{"id":1,"body":"My comment 1 new"},{"id":3,"body":"My comment 3"}]},"anArrayOfObjects":[{"id":1,"title":"My new title 1"},{"id":2,"title":"My new title 2","somethingnew":"New"}],"anArray":["first","third","fourth","ten"],"something":"alocal"}
52+
{"title":"PostHTML Components","aStringOverride":"My override string changed","anObjectOverride":{"third":"Third override item","fourth":"Fourth override item"},"computed:aComputed":true,"class":"my-demo","anObjectMerged":{"third":"Third merged item","fourth":"Fourth merged item","anObjectMerged1":{"third":"Third merged item (UPDATED?)","fourth1":"Fourth merged item"}},"post":{"title":"My post title","body":"My post body","comments":[{"id":1,"body":"My comment 1 new"},{"id":3,"body":"My comment 3"}]},"anArrayOfObjects":[{"id":1,"title":"My new title 1"},{"id":2,"title":"My new title 2","somethingnew":"New"}],"anArray":["first","third","fourth","ten"],"something":"alocal"}
5353
<div>
5454
<a href="/my-page.html">
5555
hi,

0 commit comments

Comments
 (0)