Skip to content

Commit b0cacc7

Browse files
fix: update blog config
1 parent fee4bc8 commit b0cacc7

File tree

3 files changed

+147
-133
lines changed

3 files changed

+147
-133
lines changed

website/.vitepress/config.ts

Lines changed: 135 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vitepress'
1+
import { defineConfig, DefaultTheme } from 'vitepress'
22
import llmstxt from 'vitepress-plugin-llms'
33

44
const gaScript = `
@@ -8,6 +8,139 @@ gtag('js', new Date());
88
gtag('config', 'G-EZSJ3YF2RG');
99
`
1010

11+
const sidebar: DefaultTheme.Sidebar = [
12+
{
13+
text: 'Guide',
14+
link: '/guide/introduction.html',
15+
items: [
16+
{ text: 'Quick Start', link: '/guide/quick-start.html' },
17+
{ text: 'Pattern Syntax', link: '/guide/pattern-syntax.html' },
18+
{ text: 'Rule Essentials', link: '/guide/rule-config.html', collapsed: true,
19+
items:[
20+
{ text: 'Atomic Rule', link: '/guide/rule-config/atomic-rule.html' },
21+
{ text: 'Relational Rule', link: '/guide/rule-config/relational-rule.html' },
22+
{ text: 'Composite Rule', link: '/guide/rule-config/composite-rule.html' },
23+
{ text: 'Utility Rule', link: '/guide/rule-config/utility-rule.html' },
24+
],},
25+
{
26+
text: 'Project Setup', collapsed: true, link: '/guide/scan-project.html',
27+
items: [
28+
{ text: 'Project Configuration', link: '/guide/project/project-config.html' },
29+
{ text: 'Lint Rule', link: '/guide/project/lint-rule.html' },
30+
{ text: 'Test Your Rule', link: '/guide/test-rule.html' },
31+
{ text: 'Error Report', link: '/guide/project/severity.html' },
32+
],
33+
},
34+
{ text: 'Rewrite Code', link: '/guide/rewrite-code.html', collapsed: true,
35+
items: [
36+
{ text: 'Transform Code', link: '/guide/rewrite/transform.html' },
37+
{ text: 'Rewriter Rule', link: '/guide/rewrite/rewriter.html' },
38+
],
39+
},
40+
{
41+
text: 'Tooling Overview', link: '/guide/tooling-overview.html', collapsed: true,
42+
items: [
43+
{ text: 'Editor Integration', link: '/guide/tools/editors.html' },
44+
{ text: 'JSON mode', link: '/guide/tools/json.html' },
45+
],
46+
},
47+
{ text: 'API Usage', link: '/guide/api-usage.html', collapsed: true,
48+
items:[
49+
{ text: 'JavaScript API', link: '/guide/api-usage/js-api.html' },
50+
{ text: 'Python API', link: '/guide/api-usage/py-api.html' },
51+
{ text: 'Performance Tip', link: '/guide/api-usage/performance-tip.html' },
52+
]},
53+
],
54+
collapsed: false,
55+
},
56+
{
57+
text: 'Examples',
58+
link: '/catalog',
59+
items: [
60+
{ text: 'C', link: '/catalog/c/'},
61+
{ text: 'C++', link: '/catalog/cpp/'},
62+
{ text: 'Go', link: '/catalog/go/'},
63+
{ text: 'HTML', link: '/catalog/html/'},
64+
{ text: 'Java', link: '/catalog/java/'},
65+
{ text: 'Kotlin', link: '/catalog/kotlin/'},
66+
{ text: 'Python', link: '/catalog/python/'},
67+
{ text: 'Ruby', link: '/catalog/ruby/'},
68+
{ text: 'Rust', link: '/catalog/rust/'},
69+
{ text: 'TypeScript', link: '/catalog/typescript/'},
70+
{ text: 'TSX', link: '/catalog/tsx/'},
71+
{ text: 'YAML', link: '/catalog/yaml/'},
72+
],
73+
collapsed: true,
74+
},
75+
{
76+
text: 'Reference',
77+
items: [
78+
{ text: 'Command Line Interface', link: '/reference/cli.html', collapsed: true,
79+
items: [
80+
{ text: 'ast-grep run', link: '/reference/cli/run.html' },
81+
{ text: 'ast-grep scan', link: '/reference/cli/scan.html' },
82+
{ text: 'ast-grep test', link: '/reference/cli/test.html' },
83+
{ text: 'ast-grep new', link: '/reference/cli/new.html' },
84+
],
85+
},
86+
{ text: 'Project Config', link: '/reference/sgconfig.html' },
87+
{ text: 'Rule Config', link: '/reference/yaml.html', collapsed: false,
88+
items: [
89+
{ text: 'fix', link: '/reference/yaml/fix.html' },
90+
{ text: 'transformation', link: '/reference/yaml/transformation.html' },
91+
{ text: 'rewriter', link: '/reference/yaml/rewriter.html' },
92+
],
93+
},
94+
{ text: 'Rule Object', link: '/reference/rule.html' },
95+
{ text: 'API Reference', link: '/reference/api.html' },
96+
{ text: 'Language List', link: '/reference/languages.html' },
97+
{ text: 'Playground Manual', link: '/reference/playground.html' },
98+
],
99+
collapsed: true,
100+
},
101+
{
102+
text: 'Advanced Topics',
103+
items: [
104+
{ text: 'Frequently Asked Questions', link: '/advanced/faq.html'},
105+
{ text: 'How ast-grep Works', link: '/advanced/how-ast-grep-works.html', collapsed: false,
106+
items: [
107+
{ text: 'Core Concepts', link: '/advanced/core-concepts.html'},
108+
{ text: 'Pattern Syntax', link: '/advanced/pattern-parse.html'},
109+
{ text: 'Pattern Match Algorithm', link: '/advanced/match-algorithm.html'},
110+
{ text: 'How Rewrite Works', link: '/advanced/find-n-patch.html'},
111+
] ,
112+
},
113+
{ text: 'Custom Language Support', link: '/advanced/custom-language.html'},
114+
{ text: 'Multi-Language Documents', link: '/advanced/language-injection.html'},
115+
{ text: 'Comparison with Other Tools', link: '/advanced/tool-comparison.html'},
116+
],
117+
collapsed: true,
118+
},
119+
{
120+
text: 'Contributing',
121+
items: [
122+
{ text: 'Guide', link: '/contributing/how-to.html' },
123+
{ text: 'Development', link: '/contributing/development.html' },
124+
{ text: 'Add New Language', link: '/contributing/add-lang.html' },
125+
],
126+
collapsed: true,
127+
},
128+
{
129+
text: 'Links',
130+
items: [
131+
{ text: 'Playground', link: '/playground.html' },
132+
{ text: 'Codemod Studio', link: 'https://app.codemod.com/studio' },
133+
{ text: 'Blog', link: '/blog.html' },
134+
{ text: 'VSCode', link: 'https://marketplace.visualstudio.com/items?itemName=ast-grep.ast-grep-vscode'},
135+
{ text: 'Discord', link: 'https://discord.com/invite/4YZjf6htSQ'},
136+
{ text: 'StackOverflow', link: 'https://stackoverflow.com/questions/tagged/ast-grep'},
137+
{ text: 'Reddit', link: 'https://www.reddit.com/r/astgrep/'},
138+
{ text: 'Docs.rs', link: 'https://docs.rs/ast-grep-core/latest/ast_grep_core/' },
139+
],
140+
collapsed: true,
141+
},
142+
]
143+
11144
export default defineConfig({
12145
lang: 'en-US',
13146
title: 'ast-grep',
@@ -72,138 +205,7 @@ export default defineConfig({
72205
{ text: 'Reddit', link: 'https://www.reddit.com/r/astgrep/'},
73206
{ text: 'Docs.rs', link: 'https://docs.rs/ast-grep-core/latest/ast_grep_core/' },
74207
],
75-
'/': [
76-
{
77-
text: 'Guide',
78-
link: '/guide/introduction.html',
79-
items: [
80-
{ text: 'Quick Start', link: '/guide/quick-start.html' },
81-
{ text: 'Pattern Syntax', link: '/guide/pattern-syntax.html' },
82-
{ text: 'Rule Essentials', link: '/guide/rule-config.html', collapsed: true,
83-
items:[
84-
{ text: 'Atomic Rule', link: '/guide/rule-config/atomic-rule.html' },
85-
{ text: 'Relational Rule', link: '/guide/rule-config/relational-rule.html' },
86-
{ text: 'Composite Rule', link: '/guide/rule-config/composite-rule.html' },
87-
{ text: 'Utility Rule', link: '/guide/rule-config/utility-rule.html' },
88-
],},
89-
{
90-
text: 'Project Setup', collapsed: true, link: '/guide/scan-project.html',
91-
items: [
92-
{ text: 'Project Configuration', link: '/guide/project/project-config.html' },
93-
{ text: 'Lint Rule', link: '/guide/project/lint-rule.html' },
94-
{ text: 'Test Your Rule', link: '/guide/test-rule.html' },
95-
{ text: 'Error Report', link: '/guide/project/severity.html' },
96-
],
97-
},
98-
{ text: 'Rewrite Code', link: '/guide/rewrite-code.html', collapsed: true,
99-
items: [
100-
{ text: 'Transform Code', link: '/guide/rewrite/transform.html' },
101-
{ text: 'Rewriter Rule', link: '/guide/rewrite/rewriter.html' },
102-
],
103-
},
104-
{
105-
text: 'Tooling Overview', link: '/guide/tooling-overview.html', collapsed: true,
106-
items: [
107-
{ text: 'Editor Integration', link: '/guide/tools/editors.html' },
108-
{ text: 'JSON mode', link: '/guide/tools/json.html' },
109-
],
110-
},
111-
{ text: 'API Usage', link: '/guide/api-usage.html', collapsed: true,
112-
items:[
113-
{ text: 'JavaScript API', link: '/guide/api-usage/js-api.html' },
114-
{ text: 'Python API', link: '/guide/api-usage/py-api.html' },
115-
{ text: 'Performance Tip', link: '/guide/api-usage/performance-tip.html' },
116-
]},
117-
],
118-
collapsed: false,
119-
},
120-
{
121-
text: 'Examples',
122-
link: '/catalog',
123-
items: [
124-
{ text: 'C', link: '/catalog/c/'},
125-
{ text: 'C++', link: '/catalog/cpp/'},
126-
{ text: 'Go', link: '/catalog/go/'},
127-
{ text: 'HTML', link: '/catalog/html/'},
128-
{ text: 'Java', link: '/catalog/java/'},
129-
{ text: 'Kotlin', link: '/catalog/kotlin/'},
130-
{ text: 'Python', link: '/catalog/python/'},
131-
{ text: 'Ruby', link: '/catalog/ruby/'},
132-
{ text: 'Rust', link: '/catalog/rust/'},
133-
{ text: 'TypeScript', link: '/catalog/typescript/'},
134-
{ text: 'TSX', link: '/catalog/tsx/'},
135-
{ text: 'YAML', link: '/catalog/yaml/'},
136-
],
137-
collapsed: true,
138-
},
139-
{
140-
text: 'Reference',
141-
items: [
142-
{ text: 'Command Line Interface', link: '/reference/cli.html', collapsed: true,
143-
items: [
144-
{ text: 'ast-grep run', link: '/reference/cli/run.html' },
145-
{ text: 'ast-grep scan', link: '/reference/cli/scan.html' },
146-
{ text: 'ast-grep test', link: '/reference/cli/test.html' },
147-
{ text: 'ast-grep new', link: '/reference/cli/new.html' },
148-
],
149-
},
150-
{ text: 'Project Config', link: '/reference/sgconfig.html' },
151-
{ text: 'Rule Config', link: '/reference/yaml.html', collapsed: false,
152-
items: [
153-
{ text: 'fix', link: '/reference/yaml/fix.html' },
154-
{ text: 'transformation', link: '/reference/yaml/transformation.html' },
155-
{ text: 'rewriter', link: '/reference/yaml/rewriter.html' },
156-
],
157-
},
158-
{ text: 'Rule Object', link: '/reference/rule.html' },
159-
{ text: 'API Reference', link: '/reference/api.html' },
160-
{ text: 'Language List', link: '/reference/languages.html' },
161-
{ text: 'Playground Manual', link: '/reference/playground.html' },
162-
],
163-
collapsed: true,
164-
},
165-
{
166-
text: 'Advanced Topics',
167-
items: [
168-
{ text: 'Frequently Asked Questions', link: '/advanced/faq.html'},
169-
{ text: 'How ast-grep Works', link: '/advanced/how-ast-grep-works.html', collapsed: false,
170-
items: [
171-
{ text: 'Core Concepts', link: '/advanced/core-concepts.html'},
172-
{ text: 'Pattern Syntax', link: '/advanced/pattern-parse.html'},
173-
{ text: 'Pattern Match Algorithm', link: '/advanced/match-algorithm.html'},
174-
{ text: 'How Rewrite Works', link: '/advanced/find-n-patch.html'},
175-
] ,
176-
},
177-
{ text: 'Custom Language Support', link: '/advanced/custom-language.html'},
178-
{ text: 'Multi-Language Documents', link: '/advanced/language-injection.html'},
179-
{ text: 'Comparison with Other Tools', link: '/advanced/tool-comparison.html'},
180-
],
181-
collapsed: true,
182-
},
183-
{
184-
text: 'Contributing',
185-
items: [
186-
{ text: 'Guide', link: '/contributing/how-to.html' },
187-
{ text: 'Development', link: '/contributing/development.html' },
188-
{ text: 'Add New Language', link: '/contributing/add-lang.html' },
189-
],
190-
collapsed: true,
191-
},
192-
{
193-
text: 'Links',
194-
items: [
195-
{ text: 'Playground', link: '/playground.html' },
196-
{ text: 'Codemod Studio', link: 'https://app.codemod.com/studio' },
197-
{ text: 'Blog', link: '/blog.html' },
198-
{ text: 'VSCode', link: 'https://marketplace.visualstudio.com/items?itemName=ast-grep.ast-grep-vscode'},
199-
{ text: 'Discord', link: 'https://discord.com/invite/4YZjf6htSQ'},
200-
{ text: 'StackOverflow', link: 'https://stackoverflow.com/questions/tagged/ast-grep'},
201-
{ text: 'Reddit', link: 'https://www.reddit.com/r/astgrep/'},
202-
{ text: 'Docs.rs', link: 'https://docs.rs/ast-grep-core/latest/ast_grep_core/' },
203-
],
204-
collapsed: true,
205-
},
206-
],
208+
'/': sidebar,
207209
},
208210
footer: {
209211
message: 'Made with ❤️ with Rust',

website/_data/blog.data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface Post {
88
time: number
99
string: string
1010
}
11+
description: string
1112
}
1213

1314
declare const data: Post[]
@@ -22,6 +23,8 @@ export default createContentLoader('blog/*.md', {
2223
.content,
2324
url,
2425
date: formatDate(frontmatter.date),
26+
description: frontmatter.head.find((e: any) => e[1].property === 'og:description')[1]
27+
.content,
2528
}))
2629
.sort((a, b) => b.date.time - a.date.time)
2730
},

website/src/BlogIndex.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function getDateTime(time: number) {
1717
<h2 class="title">
1818
<a :href="post.url">{{ post.title }}</a>
1919
</h2>
20+
<i class="description">{{post.description}}</i>
2021
</article>
2122
</li>
2223
</ul>
@@ -44,4 +45,12 @@ function getDateTime(time: number) {
4445
font-weight: 600;
4546
text-decoration: none;
4647
}
48+
.description {
49+
margin-top: -12px;
50+
margin-bottom: 16px;
51+
white-space: nowrap;
52+
display: block;
53+
overflow: hidden;
54+
text-overflow: ellipsis;
55+
}
4756
</style>

0 commit comments

Comments
 (0)