forked from toeverything/blocksuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add blog setup (toeverything#6170)
- Loading branch information
1 parent
1554e65
commit 0e8fa4f
Showing
15 changed files
with
245 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/docs/.vitepress/theme/components/blog-list-layout.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<template> | ||
<h1>BlockSuite Blog</h1> | ||
<div class="blog-posts-container"> | ||
<div class="blog-post" v-for="post in posts"> | ||
<a :href="post.url"> | ||
<h2 class="blog-post-title">{{ post.title }}</h2> | ||
</a> | ||
<div class="blog-post-excerpt"> | ||
{{ post.excerpt }} | ||
<a class="blog-post-read-more" :href="post.url">Read more →</a> | ||
</div> | ||
<div class="blog-post-date">{{ post.date.formatted }}</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { usePosts } from '../composables/use-posts'; | ||
const { posts } = usePosts(); | ||
</script> | ||
|
||
<style scoped> | ||
h1 { | ||
margin: auto; | ||
margin-top: 30px; | ||
margin-bottom: 50px; | ||
font-size: 50px; | ||
font-weight: bolder; | ||
line-height: 50px; | ||
text-align: center; | ||
} | ||
@media (max-width: 768px) { | ||
h1 { | ||
font-size: 40px; | ||
line-height: 40px; | ||
} | ||
} | ||
.blog-posts-container { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
} | ||
.blog-post { | ||
margin-bottom: 40px; | ||
padding-bottom: 20px; | ||
border-bottom: 1px solid #eaecef; | ||
} | ||
.blog-post-title { | ||
margin: 0; | ||
font-size: 24px; | ||
font-weight: bold; | ||
color: var(--vp-c-text-1); | ||
} | ||
.blog-post-date { | ||
font-size: 14px; | ||
color: var(--vp-c-text-3); | ||
} | ||
.blog-post-excerpt { | ||
margin-top: 10px; | ||
margin-bottom: 5px; | ||
line-height: 1.6; | ||
} | ||
.dark .blog-post { | ||
border-bottom: 1px solid #343a40; | ||
} | ||
.blog-post-read-more:hover { | ||
text-decoration: underline; | ||
} | ||
</style> |
35 changes: 35 additions & 0 deletions
35
packages/docs/.vitepress/theme/components/blog-post-meta.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<div class="blog-post-meta"> | ||
<span class="post-date">{{ post.date.formatted }}</span> by | ||
<span v-html="formattedAuthors"></span> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { computed } from 'vue'; | ||
import { usePosts } from '../composables/use-posts'; | ||
const { post } = usePosts(); | ||
const formattedAuthors = computed(() => { | ||
return post.value.authors | ||
.map( | ||
author => | ||
`<a class="author" href="${author.link}" target="_blank">${author.name}</a>` | ||
) | ||
.join(', '); | ||
}); | ||
</script> | ||
|
||
<style> | ||
.blog-post-meta { | ||
margin-top: 8px; | ||
font-size: 14px; | ||
} | ||
.author { | ||
color: var(--vp-c-text-1) !important; | ||
} | ||
.post-date { | ||
color: var(--vp-c-text-2); | ||
} | ||
</style> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { format, formatDistance } from 'date-fns'; | ||
import { createContentLoader } from 'vitepress'; | ||
|
||
interface Post { | ||
title: string; | ||
authors: { name: string; link: string }[]; | ||
url: string; | ||
date: { | ||
raw: string; | ||
time: number; | ||
formatted: string; | ||
since: string; | ||
}; | ||
} | ||
|
||
function formatDate(raw: string) { | ||
const date = new Date(raw); | ||
date.setUTCHours(8); | ||
return { | ||
raw: date.toISOString().split('T')[0], | ||
time: +date, | ||
formatted: format(date, 'yyyy/MM/dd'), | ||
since: formatDistance(date, new Date(), { addSuffix: true }), | ||
}; | ||
} | ||
|
||
const data = [] as Post[]; | ||
export { data }; | ||
|
||
export default createContentLoader('blog/*.md', { | ||
includeSrc: true, | ||
transform(raw) { | ||
return raw | ||
.filter(item => item.url !== '/blog/') | ||
.map(({ url, frontmatter }) => ({ | ||
title: frontmatter.title, | ||
authors: frontmatter.authors ?? [], | ||
excerpt: frontmatter.excerpt ?? '', | ||
url, | ||
date: formatDate(frontmatter.date), | ||
})) | ||
.sort((a, b) => b.date.time - a.date.time); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { computed } from 'vue'; | ||
import { useRoute } from 'vitepress'; | ||
import { data as posts } from './posts.data'; | ||
|
||
export function usePosts() { | ||
const route = useRoute(); | ||
const path = route.path; | ||
|
||
function findCurrentIndex() { | ||
const result = posts.findIndex(p => p.url === route.path); | ||
if (result === -1) console.error(`blog post missing: ${route.path}`); | ||
return result; | ||
} | ||
|
||
const post = computed(() => posts[findCurrentIndex()]); | ||
|
||
return { posts, post, path }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
--- | ||
layout: doc | ||
layout: BlogListLayout | ||
title: Blog | ||
--- | ||
|
||
- [Building Document-Centric, CRDT-Native Editors](./document-centric) | ||
- [CRDT-Native Data Flow](./crdt-native-data-flow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./.vitepress"], | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.