Skip to content

Commit aa0ee10

Browse files
feat: add blog page
1 parent 7e79d2b commit aa0ee10

File tree

5 files changed

+119
-4
lines changed

5 files changed

+119
-4
lines changed

website/_data/blog.data.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { createContentLoader } from 'vitepress'
2+
3+
interface Post {
4+
title: string
5+
url: string
6+
date: {
7+
time: number
8+
string: string
9+
}
10+
}
11+
12+
declare const data: Post[]
13+
export { data }
14+
15+
export default createContentLoader('blog/*.md', {
16+
// excerpt: true,
17+
transform(raw): Post[] {
18+
return raw
19+
.map(({ url, frontmatter }) => ({
20+
title: frontmatter.head.find((e: any) => e[1].property === 'og:title')[1]
21+
.content,
22+
url,
23+
date: formatDate(frontmatter.date),
24+
}))
25+
.sort((a, b) => b.date.time - a.date.time)
26+
},
27+
})
28+
29+
function formatDate(raw: string): Post['date'] {
30+
const date = new Date(raw)
31+
date.setUTCHours(12)
32+
return {
33+
time: +date,
34+
string: date.toLocaleDateString('en-US', {
35+
year: 'numeric',
36+
month: 'long',
37+
day: 'numeric',
38+
}),
39+
}
40+
}

website/blog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar: false
3+
outline: false
4+
---
5+
6+
# ast-grep Blog
7+
8+
<script setup>
9+
import BlogIndex from './src/BlogIndex.vue'
10+
</script>
11+
12+
<BlogIndex/>

website/blog/code-search-design-space.md renamed to website/blog/code-search-design-space.md.draft

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
---
2+
author:
3+
- name: Herrington Darkholme
4+
sidebar: false
5+
date: 2024-12-23
6+
head:
7+
- - meta
8+
- property: og:type
9+
content: website
10+
- - meta
11+
- property: og:title
12+
content: Design Space for Code Search
13+
- - meta
14+
- property: og:url
15+
content: https://ast-grep.github.io/blog/code-search-design-space.html
16+
- - meta
17+
- property: og:description
18+
content: A review of the design space for code search tools.
19+
---
20+
121
# Design Space for Code Search
222

323
Code search is a critical tool for developers, enabling them to find, understand, and reuse existing code.
@@ -115,4 +135,4 @@ its subtrees are compared against AST subtrees of source files in the repository
115135

116136
* Semantics-Based Code Search Using Input/Output Examples https://seg.nju.edu.cn/uploadPublication/copyright/1201675797649.pdf
117137
* encodes Java methods in code repositories into path constraints via symbolic analysis and leverages SMT solvers to
118-
find the methods whose path constraints can satisfy the given input/output examples
138+
find the methods whose path constraints can satisfy the given input/output examples

website/blog/index.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

website/src/BlogIndex.vue

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script setup lang="ts">
2+
import { data as posts } from '../_data/blog.data'
3+
4+
function getDateTime(time: number) {
5+
return new Date(time).toISOString()
6+
}
7+
</script>
8+
9+
<template>
10+
<ul class="blog-list">
11+
<li class="blog-entry" v-for="post of posts">
12+
<article>
13+
<time :datetime="getDateTime(post.date.time)">{{
14+
post.date.string
15+
}}</time>
16+
<h2 class="title">
17+
<a :href="post.url">{{ post.title }}</a>
18+
</h2>
19+
</article>
20+
</li>
21+
</ul>
22+
</template>
23+
24+
<style scoped>
25+
.blog-list {
26+
list-style-type: none;
27+
padding: 0;
28+
}
29+
.blog-entry {
30+
margin-top: 3em;
31+
border-bottom: 1px solid var(--vp-c-divider);
32+
}
33+
.blog-entry time {
34+
font-size: 14px;
35+
}
36+
.title {
37+
border: none;
38+
margin-top: 0;
39+
padding-top: 0;
40+
font-size: 22px;
41+
}
42+
.title a {
43+
font-weight: 600;
44+
text-decoration: none;
45+
}
46+
</style>

0 commit comments

Comments
 (0)