post excerpts and wrapping post components
This commit is contained in:
parent
9c0337cd46
commit
d4b3052d73
|
@ -30,4 +30,8 @@ import TheFooter from './components/TheFooter.vue'
|
||||||
border-width: 0 5px;
|
border-width: 0 5px;
|
||||||
border-color: #d54e53;
|
border-color: #d54e53;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding-top: 1em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import Link from '../components/Link.vue'
|
||||||
|
|
||||||
|
const blog = { title: "blog", path: "/", url: "/" }
|
||||||
|
const pics = { title: "pics", path: "/pics", url: "/pics.html" }
|
||||||
|
const about = { title: "about", path: "/about", url: "/about.html" }
|
||||||
|
const cv = { title: "cv", path: "/cv", url: "/cv.html" }
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="sitetitle">
|
<div class="sitetitle">
|
||||||
<div class="titlecontainer">
|
<div class="titlecontainer">
|
||||||
|
@ -6,6 +15,14 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<nav><ul>
|
||||||
|
<li><Link :to="blog"/></li>
|
||||||
|
<li><Link :to="pics"/></li>
|
||||||
|
<li><Link :to="about"/></li>
|
||||||
|
<li><Link :to="cv"/></li>
|
||||||
|
</ul></nav>
|
||||||
|
<hr>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -38,4 +55,16 @@
|
||||||
.titlecontainer span {
|
.titlecontainer span {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
text-align: center;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -7,14 +7,13 @@ const props = defineProps<{
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<article>
|
<article>
|
||||||
<slot>
|
<h1>{{ title }}</h1>
|
||||||
post content goes here
|
<slot></slot>
|
||||||
</slot>
|
|
||||||
</article>
|
</article>
|
||||||
<hr>
|
<hr>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Originally authored: {{ props.date.toLocaleDateString("en-US") }}</li>
|
<li>Originally authored: {{ props.date.toLocaleDateString("sv-SE") }}</li>
|
||||||
<ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,32 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import posts from '../posts'
|
import posts from '../posts'
|
||||||
import Link from '../components/Link.vue'
|
import Link from '../components/Link.vue'
|
||||||
|
import type { MarkdownItEnv } from '@mdit-vue/types';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="post in posts">
|
<li v-for="post in posts">
|
||||||
<Link :to="post"/>
|
<div class="posthead">
|
||||||
|
<Link :to="post"/>
|
||||||
|
<span>{{ post.date.toLocaleDateString("sv-SE") }}</span>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div v-html="post.excerpt"></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.posthead {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -36,3 +36,9 @@ a:visited {
|
||||||
a:hover {
|
a:hover {
|
||||||
color: #70c0b1;
|
color: #70c0b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
color: #808080;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px dashed;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @ts-nocheck
|
|
||||||
import type { ComponentOptions } from 'vue'
|
import type { ComponentOptions } from 'vue'
|
||||||
|
import { h, defineComponent } from 'vue'
|
||||||
|
import ThePost from '../components/ThePost.vue'
|
||||||
|
|
||||||
export type Post = {
|
export type Post = {
|
||||||
title : string,
|
title : string,
|
||||||
|
@ -7,6 +8,7 @@ export type Post = {
|
||||||
slug : string,
|
slug : string,
|
||||||
path : string,
|
path : string,
|
||||||
url : string,
|
url : string,
|
||||||
|
excerpt : string,
|
||||||
component : ComponentOptions,
|
component : ComponentOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,15 +16,38 @@ const imports = await Promise.all(
|
||||||
Object.values(import.meta.glob('./*.md')).map((m) => m())
|
Object.values(import.meta.glob('./*.md')).map((m) => m())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
const posts : Post[] = imports.map((post) => {
|
const posts : Post[] = imports.map((post) => {
|
||||||
|
// @ts-ignore
|
||||||
const slug = post.default.__name
|
const slug = post.default.__name
|
||||||
const path = "/posts/" + slug
|
const path = "/posts/" + slug
|
||||||
const url = path + ".html"
|
const url = path + ".html"
|
||||||
|
// @ts-ignore
|
||||||
|
const date = new Date(post.date)
|
||||||
|
// @ts-ignore
|
||||||
|
const title = post.title
|
||||||
return {
|
return {
|
||||||
title: post.title,
|
// @ts-ignore
|
||||||
date: new Date(post.date),
|
excerpt: post.excerpt,
|
||||||
slug, path, url,
|
title, date, slug, path, url,
|
||||||
component: post.default
|
component: defineComponent(
|
||||||
|
(props) => {
|
||||||
|
return () => {
|
||||||
|
return h(
|
||||||
|
ThePost,
|
||||||
|
{
|
||||||
|
date: date,
|
||||||
|
title: title
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// @ts-ignore
|
||||||
|
default: post.default.render
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ props: {} }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,13 @@ export default {
|
||||||
}),
|
}),
|
||||||
Pages(),
|
Pages(),
|
||||||
Markdown({
|
Markdown({
|
||||||
|
excerpt: true,
|
||||||
|
frontmatterOptions: {
|
||||||
|
grayMatterOptions: {
|
||||||
|
excerpt: true,
|
||||||
|
excerpt_separator: '<!--more-->',
|
||||||
|
},
|
||||||
|
},
|
||||||
headEnabled: true,
|
headEnabled: true,
|
||||||
markdownItSetup(md) {
|
markdownItSetup(md) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
Loading…
Reference in New Issue
Block a user