diff --git a/apps/landing/src/composables/blogs.ts b/apps/landing/src/composables/blogs.ts
new file mode 100644
index 000000000..cd106b039
--- /dev/null
+++ b/apps/landing/src/composables/blogs.ts
@@ -0,0 +1,67 @@
+import { onMounted, onUnmounted, readonly, ref } from 'vue'
+import snarkdown from 'snarkdown'
+
+const initializeComposable = ref(false)
+
+type blog = {
+ title: string;
+ content: string;
+ timestamp: string;
+ type: string;
+ id: string;
+};
+
+const allBlogs = ref([] as blog[])
+const loadingBlogs = ref(true)
+
+export default function useBlogs() {
+ async function getContentOfBlog(itemId: string) {
+ const response = await fetch(`http://localhost:3003/api/hackmd/${itemId}`)
+ const json = await response.json()
+ const md = snarkdown(json.content)
+
+ return md
+ }
+
+ onMounted(async () => {
+ if (!initializeComposable.value) {
+ loadingBlogs.value = true
+ try {
+ const response = await fetch('http://localhost:3003/api/hackmd')
+ const jsonList = await response.json()
+ const blogList = []
+
+ for (let i = 0; i < jsonList.length; i++) {
+ const title = jsonList[i].title
+ const content = await getContentOfBlog(jsonList[i].id)
+ const timestamp = jsonList[i].publishedAt
+ const id = jsonList[i].id
+ blogList.push({
+ title: title,
+ content: content,
+ timestamp: timestamp,
+ type: 'Blog',
+ id: id,
+ })
+ }
+
+ allBlogs.value = blogList
+ loadingBlogs.value = false
+ } catch (error) {
+ console.error('Error trying to fetch:', error)
+ loadingBlogs.value = false
+ }
+
+ initializeComposable.value = true
+ }
+ })
+
+ onUnmounted(() => {
+ initializeComposable.value = false
+ })
+
+ return {
+ allBlogs: readonly(allBlogs),
+ loadingBlogs: readonly(loadingBlogs),
+ }
+}
diff --git a/apps/landing/src/composables/router.ts b/apps/landing/src/composables/router.ts
index 2cabf6528..1799efb76 100644
--- a/apps/landing/src/composables/router.ts
+++ b/apps/landing/src/composables/router.ts
@@ -2,6 +2,7 @@ import { createWebHistory, createRouter } from 'vue-router'
import Landing from '@/pages/landing/Landing.vue'
import Changelog from '@/pages/changelog/Changelog.vue'
import Blog from '@/pages/blog/Blog.vue'
+import SingleBlog from '@/pages/blog/components/SingleBlog.vue'
const routes = [
{
path: '/',
@@ -13,6 +14,11 @@ const routes = [
name: Blog,
component: Blog,
},
+ {
+ path: '/blog/:id',
+ component: SingleBlog,
+ children: [{ path: '', name: SingleBlog, component: SingleBlog }],
+ },
{
path: '/changelog',
name: Changelog,
diff --git a/apps/landing/src/pages/blog/Blog.vue b/apps/landing/src/pages/blog/Blog.vue
index 7e7d9333f..ec6ffe5ea 100644
--- a/apps/landing/src/pages/blog/Blog.vue
+++ b/apps/landing/src/pages/blog/Blog.vue
@@ -1,56 +1,13 @@
@@ -86,33 +43,50 @@ onMounted(async () => {
-
+
-
-
- Anncouncements
-
-
-
+
+
+
+ {{ blog.type }} •
+
+
+ {{ new Date(blog.timestamp).toDateString() }}
+
-
-
+
+
+ {{ blog.title }}
+
+
+
+
+
+
+