|
1 | 1 | <template>
|
2 | 2 | <ul class="features">
|
3 |
| - <li class="feature" v-for="feat in feats"> |
| 3 | + <li class="feature"> |
4 | 4 | <hr/>
|
5 | 5 | <div class="description">
|
6 |
| - <h2>{{feat.title}}</h2> |
| 6 | + <h2>Search and Rewrite</h2> |
7 | 7 | <p>
|
8 |
| - {{feat.description}} |
| 8 | + ast-grep is a code tool for <a href="/guide/quick-start.html">structural search and replace</a>. |
| 9 | + It is like syntax-aware grep/sed! |
| 10 | + You can write code <a href="/guide/pattern-syntax.html">patterns</a> to locate and modify code, |
| 11 | + based on AST, in thousands of files, <a href="/guide/tooling-overview.html#interactive-mode">interactively</a>. |
9 | 12 | </p>
|
10 |
| - <code> |
11 |
| - {{ feat.code }} |
| 13 | + <code class="vp-code"> |
| 14 | + <span>ast-grep</span> -p '$A && $A()' -r '$A?.()' |
12 | 15 | </code>
|
13 | 16 | </div>
|
14 |
| - <img :src='feat.image' width="2004" height="1462"/> |
| 17 | + <img src='/image/search-replace.png' width="2004" height="1462"/> |
| 18 | + </li> |
| 19 | + <li class="feature"> |
| 20 | + <hr/> |
| 21 | + <div class="description"> |
| 22 | + <h2>Scan as Linter</h2> |
| 23 | + <p> |
| 24 | + ast-grep is a versatile and flexible tool for <a href="/guide/scan-project.html">linting</a> code with AST patterns. |
| 25 | + You can easily add new customized rules with <a href="/guide/rule-config.html">intuitive syntax</a> and enjoy pretty error reporting out of box. |
| 26 | + </p> |
| 27 | + <code class="vp-code"> |
| 28 | + <span>ast-grep</span> scan |
| 29 | + </code> |
| 30 | + </div> |
| 31 | + <img src='/image/yaml-scan.png' width="2004" height="1462"/> |
| 32 | + </li> |
| 33 | + <li class="feature"> |
| 34 | + <hr/> |
| 35 | + <div class="description"> |
| 36 | + <h2>Programmatic Usage</h2> |
| 37 | + <p> |
| 38 | + ast-grep also provides <a href="/guide/api-usage/js-api.html">node-js binding</a> to access syntax trees programmatically. |
| 39 | + You can use jQuery like <a href="/reference/api.html#napi">utility methods</a> to traverse syntax tree nodes. |
| 40 | + Node API also has opt-in <a href="/blog/typed-napi.html">type safety</a>. |
| 41 | + </p> |
| 42 | + <code class="vp-code"> |
| 43 | + npm install <span>@ast-grep/napi</span> |
| 44 | + </code> |
| 45 | + </div> |
| 46 | + <img src='/image/sg-napi.png' width="2004" height="1462"/> |
15 | 47 | </li>
|
16 | 48 | <hr/>
|
17 | 49 | </ul>
|
18 | 50 | </template>
|
19 |
| -<script setup lang="ts"> |
20 |
| -const feats = [ |
21 |
| - { |
22 |
| - image: '/image/search-replace.png', |
23 |
| - title: 'Search and Rewrite', |
24 |
| - description: 'ast-grep is a code tool for structural search and replace. It is like syntax-aware grep/sed! You can write code patterns to locate and modify code, based on AST, in thousands of files, interactively.', |
25 |
| - code: `sg -p '$A && $A()' -r '$A?.()'` |
26 |
| - }, |
27 |
| - { |
28 |
| - image: '/image/yaml-scan.png', |
29 |
| - title: 'Scan as Linter', |
30 |
| - description: 'ast-grep is a versatile and flexible tool for linting code with AST patterns. You can easily add new customized rules with intuitive syntax and enjoy pretty error reporting out of box.', |
31 |
| - code: `sg scan`, |
32 |
| - }, |
33 |
| - { |
34 |
| - image: '/image/sg-napi.png', |
35 |
| - title: 'Programmatic Usage', |
36 |
| - description: 'ast-grep also provides node-js binding for manipulating syntax trees programmatically. You can use jQuery like utility methods to traverse and manipulate syntax tree nodes, or use operators to compose complex matching from simple patterns.', |
37 |
| - code: `npm install @ast-grep/napi`, |
38 |
| - }, |
39 |
| -] |
40 |
| -</script> |
41 | 51 | <style scoped>
|
42 | 52 | .features {
|
43 | 53 | margin-top: -2em;
|
@@ -65,6 +75,11 @@ const feats = [
|
65 | 75 | padding: 0em 2em 2em;
|
66 | 76 | text-align: center;
|
67 | 77 | }
|
| 78 | + .description a { |
| 79 | + text-decoration: underline; |
| 80 | + text-decoration-style: dotted; |
| 81 | + font-style: italic; |
| 82 | + } |
68 | 83 | @media (min-width: 640px) {
|
69 | 84 | .description {
|
70 | 85 | padding: 0em 4em 2em;
|
@@ -93,6 +108,10 @@ const feats = [
|
93 | 108 | background-color: var(--vp-c-bg-soft);
|
94 | 109 | transition: border-color 0.25s, background-color 0.25s;
|
95 | 110 | }
|
| 111 | + code span { |
| 112 | + --shiki-light: #6F42C1; |
| 113 | + --shiki-dark: #B392F0; |
| 114 | + } |
96 | 115 | hr {
|
97 | 116 | width: 100%;
|
98 | 117 | border: none;
|
|
0 commit comments