Author SHA1 Message Date
klemek 6127e132e4 fix: faster page loading with no async 2026-04-27 13:27:48 +02:00
klemek 89b83e3e43 feat: updated on and better vue layout 2026-04-27 11:33:06 +02:00
klemek 39cf54624a fix: add back home button on about page 2026-04-27 10:59:11 +02:00
klemek 722548118a feat: about page and better config 2026-04-26 22:35:24 +02:00
klemek a5b24dc9bf feat: custom not found page 2026-04-26 22:10:44 +02:00
18 changed files with 138 additions and 111 deletions
+2 -3
View File
@@ -21,9 +21,8 @@ bun run build
- [x] config in sub repo - [x] config in sub repo
- [x] copyright - [x] copyright
- [x] nav bar on top - [x] nav bar on top
- [ ] date updated - [x] date updated
- [ ] archive page - [ ] archive page
- [ ] about page - [x] about page
- [ ] contact/links
- [ ] link to previous/next article - [ ] link to previous/next article
- [ ] proper docs - [ ] proper docs
+14 -11
View File
@@ -1,12 +1,15 @@
{ {
"base_url": "http://localhost/", "base_url": "http://localhost/",
"title": "<i icon=notepad-text></i> My Blog", "title": "<i icon=notepad-text></i> My Blog",
"signature": "By <b>Me</b>", "signature": "By <b>Me</b>",
"lang": "en", "lang": "en",
"custom_head": "", "custom_head": "",
"home_count": 5, "home_count": 5,
"rss_link": "<i icon=rss></i> RSS", "rss_link": "<i icon=rss></i> RSS",
"back_link": "<i icon=undo-2></i> Back to home", "about_link": "<i icon=info></i> ABOUT",
"published_on": "Published on", "back_link": "<i icon=undo-2></i> Back to home",
"copyright": "<a style=\"text-decoration:none;color:inherit;\" target=_blank href=\"https://creativecommons.org/licenses/by-nc/4.0/\">CC BY-NC</a>" "published_on": "Published on",
} "updated_on": "Updated on",
"authored": "By",
"copyright": "<a style=\"text-decoration:none;color:inherit;\" target=_blank href=\"https://creativecommons.org/licenses/by-nc/4.0/\">CC BY-NC</a>"
}
+5 -9
View File
@@ -22,7 +22,8 @@ https://www.joshwcomeau.com/css/custom-css-reset/
3. Allow percentage-based heights in the application 3. Allow percentage-based heights in the application
*/ */
html, html,
body, div#app { body,
div#app {
height: 100%; height: 100%;
} }
/* /*
@@ -178,14 +179,9 @@ nav .nav-title {
nav .nav-items { nav .nav-items {
display: flex; display: flex;
gap: 0.5em;
} }
.article-published { .article-info {
font-style: italic; font-style: italic;
}
.link-home {
text-decoration: none;
float: right;
line-height: 2.4;
} }
-1
View File
@@ -1,6 +1,5 @@
{ {
"lockfileVersion": 1, "lockfileVersion": 1,
"configVersion": 0,
"workspaces": { "workspaces": {
"": { "": {
"name": "md-blog", "name": "md-blog",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "md-blog", "name": "md-blog",
"version": "1.6.0", "version": "1.9.1",
"private": true, "private": true,
"type": "module", "type": "module",
"repository": "https://github.com/klemek/md-blog", "repository": "https://github.com/klemek/md-blog",
+7 -24
View File
@@ -1,29 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import hljs from 'highlight.js' import PageFooter from '@components/PageFooter.vue'
import { createIcons, icons } from 'lucide' import NavBar from '@components/NavBar.vue'
import { onMounted, onUpdated, nextTick } from 'vue'
import mermaid from 'mermaid'
async function update() {
setTimeout(async () => {
await nextTick()
hljs.highlightAll()
createIcons({
icons,
nameAttr: 'icon',
attrs: {
width: '1.1em',
height: '1.1em',
},
})
mermaid.run()
}, 100)
}
onMounted(update)
onUpdated(update)
</script> </script>
<template> <template>
<RouterView @vue:mounted="update" @vue:updated="update" /> <main>
<NavBar />
<RouterView />
<PageFooter />
</main>
</template> </template>
+9
View File
@@ -0,0 +1,9 @@
<script setup lang="ts">
import { BACK_LINK } from '@lib/config'
</script>
<template>
<template v-if="$route.fullPath != '/'">
<RouterLink class="link-back" to="/"><span v-html="BACK_LINK"></span></RouterLink>
</template>
</template>
+2 -1
View File
@@ -1,11 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { BASE_URL, TITLE, RSS_LINK } from '@lib/config' import { BASE_URL, TITLE, RSS_LINK, ABOUT_LINK } from '@lib/config'
</script> </script>
<template> <template>
<nav> <nav>
<RouterLink to="/" class="nav-title"><span v-html="TITLE"></span></RouterLink> <RouterLink to="/" class="nav-title"><span v-html="TITLE"></span></RouterLink>
<span class="nav-items"> <span class="nav-items">
<RouterLink to="/about/"><span v-html="ABOUT_LINK"></span></RouterLink>
<a :href="BASE_URL + 'atom.xml'" v-html="RSS_LINK"></a> <a :href="BASE_URL + 'atom.xml'" v-html="RSS_LINK"></a>
</span> </span>
</nav> </nav>
+2 -1
View File
@@ -7,7 +7,8 @@ export interface ArticleMetadata {
path: string path: string
title: string title: string
date: Date date: Date
author: string updated?: Date
author?: string
thumbnail?: string thumbnail?: string
draft?: boolean draft?: boolean
} }
+24 -1
View File
@@ -1,5 +1,23 @@
import type { MarkdownData, Article, ArticleMetadata } from '@interfaces' import type { MarkdownData, Article, ArticleMetadata } from '@interfaces'
import katex from 'katex' import katex from 'katex'
import { nextTick } from 'vue'
import hljs from 'highlight.js'
import mermaid from 'mermaid'
import { createIcons, icons } from 'lucide'
export async function updateDynamicContent() {
await nextTick()
hljs.highlightAll()
createIcons({
icons,
nameAttr: 'icon',
attrs: {
width: '1.1em',
height: '1.1em',
},
})
mermaid.run()
}
function parseMetadata( function parseMetadata(
srcAttributes: Record<string, unknown>, srcAttributes: Record<string, unknown>,
@@ -10,7 +28,12 @@ function parseMetadata(
path: pathPrefix, path: pathPrefix,
title: title:
(draft ? '[DRAFT] ' : '') + decodeURIComponent((srcAttributes.title as string) ?? 'Untitled'), (draft ? '[DRAFT] ' : '') + decodeURIComponent((srcAttributes.title as string) ?? 'Untitled'),
date: new Date(Date.parse((srcAttributes.date as string) ?? '')), date: (srcAttributes.date as string | undefined)
? new Date(Date.parse(srcAttributes.date as string))
: new Date(),
updated: (srcAttributes.updated as string | undefined)
? new Date(Date.parse(srcAttributes.updated as string))
: undefined,
author: decodeURIComponent((srcAttributes.author as string) ?? ''), author: decodeURIComponent((srcAttributes.author as string) ?? ''),
thumbnail: (srcAttributes.thumbnail as string) ?? '', thumbnail: (srcAttributes.thumbnail as string) ?? '',
draft: draft, draft: draft,
+11 -7
View File
@@ -1,14 +1,18 @@
import packageJson from '@/../package.json' import packageJson from '@/../package.json'
import articlesConfig from '@articles/config.json'
export const NAME: string = packageJson.name export const NAME: string = packageJson.name
export const VERSION: string = packageJson.version export const VERSION: string = packageJson.version
export const REPOSITORY: string = packageJson.repository export const REPOSITORY: string = packageJson.repository
export const TITLE: string = import.meta.env.VITE_APP_TITLE export const TITLE: string = articlesConfig['title']
export const SIGNATURE: string = import.meta.env.VITE_APP_SIGNATURE export const SIGNATURE: string = articlesConfig['signature']
export const COPYRIGHT: string = import.meta.env.VITE_APP_COPYRIGHT export const COPYRIGHT: string = articlesConfig['copyright']
export const RSS_LINK: string = import.meta.env.VITE_APP_RSS_LINK export const RSS_LINK: string = articlesConfig['rss_link']
export const BACK_LINK: string = import.meta.env.VITE_APP_BACK_LINK export const BACK_LINK: string = articlesConfig['back_link']
export const HOME_COUNT: number = parseInt(import.meta.env.VITE_APP_HOME_COUNT) export const ABOUT_LINK: string = articlesConfig['about_link']
export const PUBLISHED_ON: string = import.meta.env.VITE_APP_PUBLISHED_ON export const HOME_COUNT: number = articlesConfig['home_count']
export const PUBLISHED_ON: string = articlesConfig['published_on']
export const UPDATED_ON: string = articlesConfig['updated_on']
export const AUTHORED: string = articlesConfig['authored']
export const BASE_URL: string = import.meta.env.BASE_URL export const BASE_URL: string = import.meta.env.BASE_URL
export const PROD: boolean = import.meta.env.PROD export const PROD: boolean = import.meta.env.PROD
+5 -3
View File
@@ -1,12 +1,14 @@
import ArticleView from '@views/ArticleView.vue'
import HomeView from '@views/HomeView.vue'
import NotFoundView from '@views/NotFoundView.vue'
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@views/HomeView.vue'
import AboutView from '@views/AboutView.vue'
import ArticleView from '@views/ArticleView.vue'
import NotFoundView from '@views/NotFoundView.vue'
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
routes: [ routes: [
{ path: '/', component: HomeView }, { path: '/', component: HomeView },
{ path: '/about/', component: AboutView },
{ path: '/articles/:pathMatch(.*)/', component: ArticleView }, { path: '/articles/:pathMatch(.*)/', component: ArticleView },
{ path: '/:pathMatch(.*)', component: NotFoundView }, { path: '/:pathMatch(.*)', component: NotFoundView },
], ],
+15
View File
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { onMounted, onUpdated } from 'vue'
import { updateDynamicContent } from '@lib/articles'
import { html } from '@articles/about.md'
onMounted(updateDynamicContent)
onUpdated(updateDynamicContent)
</script>
<template>
<div class="article">
<div v-html="html"></div>
<BackHomeButton />
</div>
</template>
+22 -21
View File
@@ -1,14 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Article } from '@interfaces' import type { Article } from '@interfaces'
import { ref, onBeforeMount } from 'vue' import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
import { loadArticle } from '@lib/articles' import { loadArticle, updateDynamicContent } from '@lib/articles'
import { useRoute, onBeforeRouteUpdate, type RouteLocation } from 'vue-router' import { useRoute, onBeforeRouteUpdate, type RouteLocation } from 'vue-router'
import NotFoundView from './NotFoundView.vue'
import { simpleDateFormat } from '@lib/dates' import { simpleDateFormat } from '@lib/dates'
import { BACK_LINK, PUBLISHED_ON, SIGNATURE, TITLE } from '@lib/config' import { AUTHORED, PUBLISHED_ON, SIGNATURE, TITLE, UPDATED_ON } from '@lib/config'
import PageFooter from '@components/PageFooter.vue'
import { stripHTML } from '@lib/strings' import { stripHTML } from '@lib/strings'
import NavBar from '@components/NavBar.vue' import BackHomeButton from '@components/BackHomeButton.vue'
import NotFoundView from '@views/NotFoundView.vue'
const article = ref<Article | null>(null) const article = ref<Article | null>(null)
const loading = ref<boolean>(true) const loading = ref<boolean>(true)
@@ -20,27 +19,32 @@ async function loadPage(target: RouteLocation) {
window.document.title = window.document.title =
stripHTML(TITLE) + ' — ' + stripHTML(article.value?.metadata.title ?? 'Not Found') stripHTML(TITLE) + ' — ' + stripHTML(article.value?.metadata.title ?? 'Not Found')
loading.value = false loading.value = false
await updateDynamicContent()
} }
onBeforeMount(() => loadPage(route)) onBeforeMount(() => loadPage(route))
onBeforeRouteUpdate(loadPage) onBeforeRouteUpdate(loadPage)
onMounted(updateDynamicContent)
onUpdated(updateDynamicContent)
</script> </script>
<template> <template>
<template v-if="loading"> <template v-if="!loading && !article">
<main></main>
</template>
<template v-else-if="!article">
<NotFoundView /> <NotFoundView />
</template> </template>
<template v-else> <div v-if="!loading" class="article">
<main class="article"> <template v-if="!loading && article">
<NavBar />
<div class="article-header"> <div class="article-header">
<RouterLink class="link-home" to="/"><i icon="undo-2"></i></RouterLink>
<h1 class="article-title" v-html="article.metadata.title"></h1> <h1 class="article-title" v-html="article.metadata.title"></h1>
<div class="article-published"> <div class="article-info">
<span v-if="article.metadata.author"
><span v-html="AUTHORED"></span> <span v-html="article.metadata.author"></span>
</span>
<span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(article.metadata.date) }} <span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(article.metadata.date) }}
<span v-if="article.metadata.updated"
> <span v-html="UPDATED_ON"></span>
{{ simpleDateFormat(article.metadata.updated) }}</span
>
</div> </div>
<img <img
v-if="article.metadata.thumbnail" v-if="article.metadata.thumbnail"
@@ -51,10 +55,7 @@ onBeforeRouteUpdate(loadPage)
</div> </div>
<div class="article-text" v-html="article.html"></div> <div class="article-text" v-html="article.html"></div>
<div class="article-signature" v-html="SIGNATURE"></div> <div class="article-signature" v-html="SIGNATURE"></div>
<template v-if="$route.fullPath != '/'"> <BackHomeButton />
<RouterLink class="link-back" to="/"><span v-html="BACK_LINK"></span></RouterLink> </template>
</template> </div>
<PageFooter />
</main>
</template>
</template> </template>
+11 -10
View File
@@ -1,14 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onBeforeMount } from 'vue' import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
import { listArticles } from '@lib/articles' import { listArticles, updateDynamicContent } from '@lib/articles'
import type { ArticleMetadata } from '@interfaces' import type { ArticleMetadata } from '@interfaces'
import { simpleDateFormat } from '@lib/dates' import { simpleDateFormat } from '@lib/dates'
import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config' import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config'
import PageFooter from '@components/PageFooter.vue' import { stripHTML } from '@lib/strings'
import { stripHTML } from '@/lib/strings'
import NavBar from '@components/NavBar.vue'
const articles = ref<ArticleMetadata[]>([]) const articles = ref<ArticleMetadata[]>([])
const loading = ref<boolean>(true)
onBeforeMount(async () => { onBeforeMount(async () => {
const newArticles = (await listArticles()) const newArticles = (await listArticles())
@@ -16,17 +15,20 @@ onBeforeMount(async () => {
.slice(0, HOME_COUNT) .slice(0, HOME_COUNT)
articles.value.splice(0, articles.value.length, ...newArticles) articles.value.splice(0, articles.value.length, ...newArticles)
window.document.title = stripHTML(TITLE) + ' — Home' window.document.title = stripHTML(TITLE) + ' — Home'
loading.value = false
await updateDynamicContent()
}) })
onMounted(updateDynamicContent)
onUpdated(updateDynamicContent)
</script> </script>
<template> <template>
<main class="home"> <div v-if="!loading" class="home">
<NavBar />
<template v-for="(metadata, index) in articles" v-bind:key="index"> <template v-for="(metadata, index) in articles" v-bind:key="index">
<div v-if="(!metadata.draft || !PROD) && metadata.path" class="article-item"> <div v-if="(!metadata.draft || !PROD) && metadata.path" class="article-item">
<RouterLink :to="metadata.path"> <RouterLink :to="metadata.path">
<h2 v-html="metadata.title"></h2> <h2 v-html="metadata.title"></h2>
<span class="article-published" <span class="article-info"
><span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(metadata.date) }}</span ><span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(metadata.date) }}</span
> >
<img <img
@@ -37,6 +39,5 @@ onBeforeMount(async () => {
</RouterLink> </RouterLink>
</div> </div>
</template> </template>
<PageFooter /> </div>
</main>
</template> </template>
+6 -12
View File
@@ -1,18 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { TITLE } from '@lib/config' import { onMounted, onUpdated } from 'vue'
import { stripHTML } from '@lib/strings' import { updateDynamicContent } from '@lib/articles'
import PageFooter from '@components/PageFooter.vue' import { html } from '@articles/not_found.md'
import { onBeforeMount } from 'vue'
onBeforeMount(() => { onMounted(updateDynamicContent)
window.document.title = stripHTML(TITLE) + ' — Not Found' onUpdated(updateDynamicContent)
})
</script> </script>
<template> <template>
<main> <div class="article" v-html="html"></div>
<NavBar />
<h1>Page not found</h1>
<PageFooter />
</main>
</template> </template>
-6
View File
@@ -14,13 +14,7 @@ export default ({ mode }: { mode: string }) => {
process.env.VITE_APP_TITLE = articlesConfig['title'] process.env.VITE_APP_TITLE = articlesConfig['title']
process.env.VITE_APP_TITLE_NO_HTML = articlesConfig['title'].replace(/(<([^>]+)>)/gi, '').trim() process.env.VITE_APP_TITLE_NO_HTML = articlesConfig['title'].replace(/(<([^>]+)>)/gi, '').trim()
process.env.VITE_APP_LANG = articlesConfig['lang'] process.env.VITE_APP_LANG = articlesConfig['lang']
process.env.VITE_APP_SIGNATURE = articlesConfig['signature']
process.env.VITE_CUSTOM_HEAD = articlesConfig['custom_head'] process.env.VITE_CUSTOM_HEAD = articlesConfig['custom_head']
process.env.VITE_APP_COPYRIGHT = articlesConfig['copyright']
process.env.VITE_APP_RSS_LINK = articlesConfig['rss_link']
process.env.VITE_APP_BACK_LINK = articlesConfig['back_link']
process.env.VITE_APP_HOME_COUNT = articlesConfig['home_count'].toString()
process.env.VITE_APP_PUBLISHED_ON = articlesConfig['published_on']
return defineConfig({ return defineConfig({
plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })], plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })],
Vendored
+2
View File
@@ -23,3 +23,5 @@ declare module '*.md' {
// Modify below per your usage // Modify below per your usage
export { attributes, toc, html, ReactComponent, VueComponent, VueComponentWith } export { attributes, toc, html, ReactComponent, VueComponent, VueComponentWith }
} }
declare module '*.vue'