Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89b83e3e43 | ||
|
|
39cf54624a | ||
|
|
722548118a | ||
|
|
a5b24dc9bf |
@@ -20,7 +20,8 @@ jobs:
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
- run: git clone ${{ vars.ARTICLES_REPOSITORY }} articles
|
||||
- run: bun run build
|
||||
- run: bun run build-only
|
||||
- run: bun run post-build
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: production-files
|
||||
|
||||
@@ -21,9 +21,8 @@ bun run build
|
||||
- [x] config in sub repo
|
||||
- [x] copyright
|
||||
- [x] nav bar on top
|
||||
- [ ] date updated
|
||||
- [x] date updated
|
||||
- [ ] archive page
|
||||
- [ ] about page
|
||||
- [ ] contact/links
|
||||
- [x] about page
|
||||
- [ ] link to previous/next article
|
||||
- [ ] proper docs
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"base_url": "http://localhost/",
|
||||
"title": "<i icon=notepad-text></i> My Blog",
|
||||
"signature": "By <b>Me</b>",
|
||||
"lang": "en",
|
||||
"custom_head": "",
|
||||
"home_count": 5,
|
||||
"rss_link": "<i icon=rss></i> RSS",
|
||||
"back_link": "<i icon=undo-2></i> Back to home",
|
||||
"published_on": "Published on",
|
||||
"copyright": "<a style=\"text-decoration:none;color:inherit;\" target=_blank href=\"https://creativecommons.org/licenses/by-nc/4.0/\">CC BY-NC</a>"
|
||||
}
|
||||
"base_url": "http://localhost/",
|
||||
"title": "<i icon=notepad-text></i> My Blog",
|
||||
"signature": "By <b>Me</b>",
|
||||
"lang": "en",
|
||||
"custom_head": "",
|
||||
"home_count": 5,
|
||||
"rss_link": "<i icon=rss></i> RSS",
|
||||
"about_link": "<i icon=info></i> ABOUT",
|
||||
"back_link": "<i icon=undo-2></i> Back to home",
|
||||
"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>"
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ https://www.joshwcomeau.com/css/custom-css-reset/
|
||||
3. Allow percentage-based heights in the application
|
||||
*/
|
||||
html,
|
||||
body, div#app {
|
||||
body,
|
||||
div#app {
|
||||
height: 100%;
|
||||
}
|
||||
/*
|
||||
@@ -178,14 +179,9 @@ nav .nav-title {
|
||||
|
||||
nav .nav-items {
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.article-published {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.link-home {
|
||||
text-decoration: none;
|
||||
float: right;
|
||||
line-height: 2.4;
|
||||
.article-info {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 0,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "md-blog",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "md-blog",
|
||||
"version": "1.6.0",
|
||||
"version": "1.9.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"repository": "https://github.com/klemek/md-blog",
|
||||
|
||||
+8
-23
@@ -1,29 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import hljs from 'highlight.js'
|
||||
import { createIcons, icons } from 'lucide'
|
||||
import { onMounted, onUpdated, nextTick } from 'vue'
|
||||
import mermaid from 'mermaid'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
|
||||
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)
|
||||
const NavBar = defineAsyncComponent(() => import('@components/NavBar.vue'))
|
||||
const PageFooter = defineAsyncComponent(() => import('@components/PageFooter.vue'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RouterView @vue:mounted="update" @vue:updated="update" />
|
||||
<main>
|
||||
<NavBar />
|
||||
<RouterView />
|
||||
<PageFooter />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -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>
|
||||
@@ -1,11 +1,12 @@
|
||||
<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>
|
||||
|
||||
<template>
|
||||
<nav>
|
||||
<RouterLink to="/" class="nav-title"><span v-html="TITLE"></span></RouterLink>
|
||||
<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>
|
||||
</span>
|
||||
</nav>
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@ export interface ArticleMetadata {
|
||||
path: string
|
||||
title: string
|
||||
date: Date
|
||||
author: string
|
||||
updated?: Date
|
||||
author?: string
|
||||
thumbnail?: string
|
||||
draft?: boolean
|
||||
}
|
||||
|
||||
+24
-1
@@ -1,5 +1,23 @@
|
||||
import type { MarkdownData, Article, ArticleMetadata } from '@interfaces'
|
||||
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(
|
||||
srcAttributes: Record<string, unknown>,
|
||||
@@ -10,7 +28,12 @@ function parseMetadata(
|
||||
path: pathPrefix,
|
||||
title:
|
||||
(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) ?? ''),
|
||||
thumbnail: (srcAttributes.thumbnail as string) ?? '',
|
||||
draft: draft,
|
||||
|
||||
+11
-7
@@ -1,14 +1,18 @@
|
||||
import packageJson from '@/../package.json'
|
||||
import articlesConfig from '@articles/config.json'
|
||||
|
||||
export const NAME: string = packageJson.name
|
||||
export const VERSION: string = packageJson.version
|
||||
export const REPOSITORY: string = packageJson.repository
|
||||
export const TITLE: string = import.meta.env.VITE_APP_TITLE
|
||||
export const SIGNATURE: string = import.meta.env.VITE_APP_SIGNATURE
|
||||
export const COPYRIGHT: string = import.meta.env.VITE_APP_COPYRIGHT
|
||||
export const RSS_LINK: string = import.meta.env.VITE_APP_RSS_LINK
|
||||
export const BACK_LINK: string = import.meta.env.VITE_APP_BACK_LINK
|
||||
export const HOME_COUNT: number = parseInt(import.meta.env.VITE_APP_HOME_COUNT)
|
||||
export const PUBLISHED_ON: string = import.meta.env.VITE_APP_PUBLISHED_ON
|
||||
export const TITLE: string = articlesConfig['title']
|
||||
export const SIGNATURE: string = articlesConfig['signature']
|
||||
export const COPYRIGHT: string = articlesConfig['copyright']
|
||||
export const RSS_LINK: string = articlesConfig['rss_link']
|
||||
export const BACK_LINK: string = articlesConfig['back_link']
|
||||
export const ABOUT_LINK: string = articlesConfig['about_link']
|
||||
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 PROD: boolean = import.meta.env.PROD
|
||||
|
||||
+7
-3
@@ -1,12 +1,16 @@
|
||||
import ArticleView from '@views/ArticleView.vue'
|
||||
import HomeView from '@views/HomeView.vue'
|
||||
import NotFoundView from '@views/NotFoundView.vue'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
const AboutView = defineAsyncComponent(() => import('@views/AboutView.vue'))
|
||||
const ArticleView = defineAsyncComponent(() => import('@views/ArticleView.vue'))
|
||||
const HomeView = defineAsyncComponent(() => import('@views/HomeView.vue'))
|
||||
const NotFoundView = defineAsyncComponent(() => import('@views/NotFoundView.vue'))
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: '/', component: HomeView },
|
||||
{ path: '/about/', component: AboutView },
|
||||
{ path: '/articles/:pathMatch(.*)/', component: ArticleView },
|
||||
{ path: '/:pathMatch(.*)', component: NotFoundView },
|
||||
],
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { ABOUT_LINK, TITLE } from '@lib/config'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
import { onBeforeMount, onMounted, onUpdated, ref } from 'vue'
|
||||
import { updateDynamicContent } from '@lib/articles'
|
||||
import BackHomeButton from '@components/BackHomeButton.vue'
|
||||
|
||||
const loading = ref<boolean>(true)
|
||||
const html = ref<string>('')
|
||||
|
||||
onBeforeMount(async () => {
|
||||
window.document.title = stripHTML(TITLE) + ' — ' + stripHTML(ABOUT_LINK)
|
||||
html.value = (await import('@articles/about.md')).html
|
||||
loading.value = false
|
||||
await updateDynamicContent()
|
||||
})
|
||||
onMounted(updateDynamicContent)
|
||||
onUpdated(updateDynamicContent)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!loading" class="article">
|
||||
<div v-html="html"></div>
|
||||
<BackHomeButton />
|
||||
</div>
|
||||
</template>
|
||||
+23
-21
@@ -1,14 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import type { Article } from '@interfaces'
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { loadArticle } from '@lib/articles'
|
||||
import { ref, onBeforeMount, onUpdated, onMounted, defineAsyncComponent } from 'vue'
|
||||
import { loadArticle, updateDynamicContent } from '@lib/articles'
|
||||
import { useRoute, onBeforeRouteUpdate, type RouteLocation } from 'vue-router'
|
||||
import NotFoundView from './NotFoundView.vue'
|
||||
import { simpleDateFormat } from '@lib/dates'
|
||||
import { BACK_LINK, PUBLISHED_ON, SIGNATURE, TITLE } from '@lib/config'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { AUTHORED, PUBLISHED_ON, SIGNATURE, TITLE, UPDATED_ON } from '@lib/config'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
import NavBar from '@components/NavBar.vue'
|
||||
|
||||
const BackHomeButton = defineAsyncComponent(() => import('@components/BackHomeButton.vue'))
|
||||
const NotFoundView = defineAsyncComponent(() => import('@views/NotFoundView.vue'))
|
||||
|
||||
const article = ref<Article | null>(null)
|
||||
const loading = ref<boolean>(true)
|
||||
@@ -20,27 +20,32 @@ async function loadPage(target: RouteLocation) {
|
||||
window.document.title =
|
||||
stripHTML(TITLE) + ' — ' + stripHTML(article.value?.metadata.title ?? 'Not Found')
|
||||
loading.value = false
|
||||
await updateDynamicContent()
|
||||
}
|
||||
|
||||
onBeforeMount(() => loadPage(route))
|
||||
onBeforeRouteUpdate(loadPage)
|
||||
onMounted(updateDynamicContent)
|
||||
onUpdated(updateDynamicContent)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="loading">
|
||||
<main></main>
|
||||
</template>
|
||||
<template v-else-if="!article">
|
||||
<template v-if="!loading && !article">
|
||||
<NotFoundView />
|
||||
</template>
|
||||
<template v-else>
|
||||
<main class="article">
|
||||
<NavBar />
|
||||
<div v-if="!loading" class="article">
|
||||
<template v-if="!loading && article">
|
||||
<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>
|
||||
<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-if="article.metadata.updated"
|
||||
>— <span v-html="UPDATED_ON"></span>
|
||||
{{ simpleDateFormat(article.metadata.updated) }}</span
|
||||
>
|
||||
</div>
|
||||
<img
|
||||
v-if="article.metadata.thumbnail"
|
||||
@@ -51,10 +56,7 @@ onBeforeRouteUpdate(loadPage)
|
||||
</div>
|
||||
<div class="article-text" v-html="article.html"></div>
|
||||
<div class="article-signature" v-html="SIGNATURE"></div>
|
||||
<template v-if="$route.fullPath != '/'">
|
||||
<RouterLink class="link-back" to="/"><span v-html="BACK_LINK"></span></RouterLink>
|
||||
</template>
|
||||
<PageFooter />
|
||||
</main>
|
||||
</template>
|
||||
<BackHomeButton />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+11
-10
@@ -1,14 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { listArticles } from '@lib/articles'
|
||||
import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
|
||||
import { listArticles, updateDynamicContent } from '@lib/articles'
|
||||
import type { ArticleMetadata } from '@interfaces'
|
||||
import { simpleDateFormat } from '@lib/dates'
|
||||
import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { stripHTML } from '@/lib/strings'
|
||||
import NavBar from '@components/NavBar.vue'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
|
||||
const articles = ref<ArticleMetadata[]>([])
|
||||
const loading = ref<boolean>(true)
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const newArticles = (await listArticles())
|
||||
@@ -16,17 +15,20 @@ onBeforeMount(async () => {
|
||||
.slice(0, HOME_COUNT)
|
||||
articles.value.splice(0, articles.value.length, ...newArticles)
|
||||
window.document.title = stripHTML(TITLE) + ' — Home'
|
||||
loading.value = false
|
||||
await updateDynamicContent()
|
||||
})
|
||||
onMounted(updateDynamicContent)
|
||||
onUpdated(updateDynamicContent)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="home">
|
||||
<NavBar />
|
||||
<div v-if="!loading" class="home">
|
||||
<template v-for="(metadata, index) in articles" v-bind:key="index">
|
||||
<div v-if="(!metadata.draft || !PROD) && metadata.path" class="article-item">
|
||||
<RouterLink :to="metadata.path">
|
||||
<h2 v-html="metadata.title"></h2>
|
||||
<span class="article-published"
|
||||
<span class="article-info"
|
||||
><span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(metadata.date) }}</span
|
||||
>
|
||||
<img
|
||||
@@ -37,6 +39,5 @@ onBeforeMount(async () => {
|
||||
</RouterLink>
|
||||
</div>
|
||||
</template>
|
||||
<PageFooter />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { TITLE } from '@lib/config'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { onBeforeMount } from 'vue'
|
||||
import { onBeforeMount, onMounted, onUpdated, ref } from 'vue'
|
||||
import { updateDynamicContent } from '@lib/articles'
|
||||
|
||||
onBeforeMount(() => {
|
||||
window.document.title = stripHTML(TITLE) + ' — Not Found'
|
||||
const loading = ref<boolean>(true)
|
||||
const html = ref<string>('')
|
||||
|
||||
onBeforeMount(async () => {
|
||||
window.document.title = stripHTML(TITLE)
|
||||
html.value = (await import('@articles/not_found.md')).html
|
||||
loading.value = false
|
||||
await updateDynamicContent()
|
||||
})
|
||||
onMounted(updateDynamicContent)
|
||||
onUpdated(updateDynamicContent)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<NavBar />
|
||||
<h1>Page not found</h1>
|
||||
<PageFooter />
|
||||
</main>
|
||||
<div v-if="!loading" class="article" v-html="html"></div>
|
||||
</template>
|
||||
|
||||
@@ -14,13 +14,7 @@ export default ({ mode }: { mode: string }) => {
|
||||
process.env.VITE_APP_TITLE = articlesConfig['title']
|
||||
process.env.VITE_APP_TITLE_NO_HTML = articlesConfig['title'].replace(/(<([^>]+)>)/gi, '').trim()
|
||||
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_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({
|
||||
plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })],
|
||||
|
||||
Reference in New Issue
Block a user