Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21e1469b51 | ||
|
|
649102d1aa | ||
|
|
169f35b556 | ||
|
|
8d7388835b | ||
|
|
34c410b687 |
@@ -3,6 +3,9 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: "*/30 * * * *"
|
- cron: "*/30 * * * *"
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ bun run build
|
|||||||
- [x] SPA and opengraph
|
- [x] SPA and opengraph
|
||||||
- [x] build with github actions
|
- [x] build with github actions
|
||||||
- [x] config in sub repo
|
- [x] config in sub repo
|
||||||
|
- [x] copyright
|
||||||
- [ ] nav bar on top
|
- [ ] nav bar on top
|
||||||
|
- [ ] date updated
|
||||||
- [ ] archive page
|
- [ ] archive page
|
||||||
|
- [ ] about page
|
||||||
|
- [ ] contact/links
|
||||||
- [ ] link to previous/next article
|
- [ ] link to previous/next article
|
||||||
- [ ] proper docs
|
- [ ] proper docs
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "md-blog",
|
"name": "md-blog",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@keithclark/shaderview": "git+https://github.com/keithclark/shaderview",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"katex": "^0.16.45",
|
"katex": "^0.16.45",
|
||||||
"lucide": "^1.11.0",
|
"lucide": "^1.11.0",
|
||||||
@@ -210,6 +211,8 @@
|
|||||||
|
|
||||||
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
||||||
|
|
||||||
|
"@keithclark/shaderview": ["@keithclark/shaderview@github:keithclark/shaderview#fee0cf0", {}, "keithclark-shaderview-fee0cf0"],
|
||||||
|
|
||||||
"@mermaid-js/parser": ["@mermaid-js/parser@1.1.0", "", { "dependencies": { "langium": "^4.0.0" } }, "sha512-gxK9ZX2+Fex5zu8LhRQoMeMPEHbc73UKZ0FQ54YrQtUxE1VVhMwzeNtKRPAu5aXks4FasbMe4xB4bWrmq6Jlxw=="],
|
"@mermaid-js/parser": ["@mermaid-js/parser@1.1.0", "", { "dependencies": { "langium": "^4.0.0" } }, "sha512-gxK9ZX2+Fex5zu8LhRQoMeMPEHbc73UKZ0FQ54YrQtUxE1VVhMwzeNtKRPAu5aXks4FasbMe4xB4bWrmq6Jlxw=="],
|
||||||
|
|
||||||
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.4", "", { "dependencies": { "@tybys/wasm-util": "^0.10.1" }, "peerDependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1" } }, "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow=="],
|
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.4", "", { "dependencies": { "@tybys/wasm-util": "^0.10.1" }, "peerDependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1" } }, "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow=="],
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "md-blog",
|
"name": "md-blog",
|
||||||
"version": "1.1.0",
|
"version": "1.4.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": "https://github.com/klemek/md-blog",
|
"repository": "https://github.com/klemek/md-blog",
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
"format": "prettier --write src/ *.ts *.json"
|
"format": "prettier --write src/ *.ts *.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@keithclark/shaderview": "git+https://github.com/keithclark/shaderview",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"katex": "^0.16.45",
|
"katex": "^0.16.45",
|
||||||
"lucide": "^1.11.0",
|
"lucide": "^1.11.0",
|
||||||
|
|||||||
+1
-5
@@ -28,10 +28,6 @@ function readArticleMetadata(path: string): Record<string, string> | null {
|
|||||||
const metadata: Record<string, string> = {
|
const metadata: Record<string, string> = {
|
||||||
path: path.replaceAll('/index.md', ''),
|
path: path.replaceAll('/index.md', ''),
|
||||||
}
|
}
|
||||||
const dateMatch = path.match(/(\d{4}\/\d{2}\/\d{2})/)
|
|
||||||
if (dateMatch && dateMatch[1]) {
|
|
||||||
metadata['date'] = dateMatch[1].replaceAll('/', '-')
|
|
||||||
}
|
|
||||||
do {
|
do {
|
||||||
subMatch = METADATA_REGEX.exec(match[1])
|
subMatch = METADATA_REGEX.exec(match[1])
|
||||||
if (subMatch && subMatch[1] && subMatch[2]) {
|
if (subMatch && subMatch[1] && subMatch[2]) {
|
||||||
@@ -93,7 +89,7 @@ if (!indexContent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const metadatas = getFiles('articles')
|
const metadatas = getFiles('articles')
|
||||||
.filter((path) => path.match(/\d{4}\/\d{2}\/\d{2}\/index.md$/))
|
.filter((path) => path.match(/\/index.md$/))
|
||||||
.map((path) => readArticleMetadata(path))
|
.map((path) => readArticleMetadata(path))
|
||||||
.filter((metadata) => !!metadata)
|
.filter((metadata) => !!metadata)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { REPOSITORY, NAME, VERSION, BASE_URL } from '@/lib/meta'
|
import { REPOSITORY, NAME, VERSION, BASE_URL, TITLE, COPYRIGHT } from '@/lib/meta'
|
||||||
|
import { stripHTML } from '@/lib/strings';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -8,10 +9,8 @@ import { REPOSITORY, NAME, VERSION, BASE_URL } from '@/lib/meta'
|
|||||||
</template>
|
</template>
|
||||||
<hr />
|
<hr />
|
||||||
<footer>
|
<footer>
|
||||||
<small>
|
{{ stripHTML(TITLE) }} © {{ new Date().getFullYear() }}, <span v-html="COPYRIGHT"></span> | Made with
|
||||||
{{ new Date().getFullYear() }} — Made with
|
<a :href="REPOSITORY">{{ NAME }} {{ VERSION }}</a> |
|
||||||
<a :href="REPOSITORY">{{ NAME }} {{ VERSION }}</a> —
|
|
||||||
<a :href="BASE_URL + 'atom.xml'"><i icon="rss"></i> RSS</a>
|
<a :href="BASE_URL + 'atom.xml'"><i icon="rss"></i> RSS</a>
|
||||||
</small>
|
|
||||||
</footer>
|
</footer>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
+23
-11
@@ -1,16 +1,14 @@
|
|||||||
import type { MarkdownData, Article, ArticleMetadata } from '@interfaces'
|
import type { MarkdownData, Article, ArticleMetadata } from '@interfaces'
|
||||||
import { dateFromParts } from './dates'
|
|
||||||
import katex from 'katex'
|
import katex from 'katex'
|
||||||
|
|
||||||
function parseMetadata(
|
function parseMetadata(
|
||||||
srcAttributes: Record<string, unknown>,
|
srcAttributes: Record<string, unknown>,
|
||||||
pathPrefix: string,
|
pathPrefix: string,
|
||||||
date: Date,
|
|
||||||
): ArticleMetadata {
|
): ArticleMetadata {
|
||||||
return {
|
return {
|
||||||
path: pathPrefix,
|
path: pathPrefix,
|
||||||
title: decodeURIComponent((srcAttributes.title as string) ?? 'Untitled'),
|
title: decodeURIComponent((srcAttributes.title as string) ?? 'Untitled'),
|
||||||
date: date,
|
date: new Date(Date.parse((srcAttributes.date as string) ?? '')),
|
||||||
author: decodeURIComponent((srcAttributes.author as string) ?? ''),
|
author: decodeURIComponent((srcAttributes.author as string) ?? ''),
|
||||||
thumbnail: (srcAttributes.thumbnail as string) ?? '',
|
thumbnail: (srcAttributes.thumbnail as string) ?? '',
|
||||||
draft: !!srcAttributes.draft,
|
draft: !!srcAttributes.draft,
|
||||||
@@ -55,7 +53,10 @@ function transformHtml(srcHtml: string): string {
|
|||||||
return outHtml
|
return outHtml
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadArticle(date: Date): Promise<Article | null> {
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
export async function loadArticleOld(date: Date): Promise<Article | null> {
|
||||||
const year = date.getFullYear().toString()
|
const year = date.getFullYear().toString()
|
||||||
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
||||||
const day = date.getDate().toString().padStart(2, '0')
|
const day = date.getDate().toString().padStart(2, '0')
|
||||||
@@ -63,7 +64,23 @@ export async function loadArticle(date: Date): Promise<Article | null> {
|
|||||||
try {
|
try {
|
||||||
const data = (await import(`@articles/${year}/${month}/${day}/index.md`)) as MarkdownData
|
const data = (await import(`@articles/${year}/${month}/${day}/index.md`)) as MarkdownData
|
||||||
return {
|
return {
|
||||||
metadata: parseMetadata(data.attributes, path, date),
|
metadata: parseMetadata(data.attributes, path),
|
||||||
|
html: transformHtml(data.html),
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
console.error(ex)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loadArticle(path: string): Promise<Article | null> {
|
||||||
|
const raw_articles = import.meta.glob('@articles/**/index.md')
|
||||||
|
const key = `/articles/${path}index.md`
|
||||||
|
if (!raw_articles[key]) return null
|
||||||
|
try {
|
||||||
|
const data = (await raw_articles[key]()) as MarkdownData
|
||||||
|
return {
|
||||||
|
metadata: parseMetadata(data.attributes, path),
|
||||||
html: transformHtml(data.html),
|
html: transformHtml(data.html),
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
@@ -79,12 +96,7 @@ export async function listArticles(): Promise<ArticleMetadata[]> {
|
|||||||
Object.keys(raw_articles).map(async (key) => {
|
Object.keys(raw_articles).map(async (key) => {
|
||||||
if (!raw_articles[key]) return null
|
if (!raw_articles[key]) return null
|
||||||
const data = (await raw_articles[key]()) as MarkdownData
|
const data = (await raw_articles[key]()) as MarkdownData
|
||||||
const match = key.match(/\/(\d+)\/(\d+)\/(\d+)\//)
|
return parseMetadata(data.attributes, key.replace('index.md', ''))
|
||||||
if (match === null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
const date = dateFromParts(match[1], match[2], match[3])
|
|
||||||
return parseMetadata(data.attributes, key.replace('index.md', ''), date)
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
).filter((item) => item !== null)
|
).filter((item) => item !== null)
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
export function dateFromParts(
|
|
||||||
year: string | undefined,
|
|
||||||
month: string | undefined,
|
|
||||||
day: string | undefined,
|
|
||||||
): Date {
|
|
||||||
return new Date(parseInt(year ?? ''), parseInt(month ?? '') - 1, parseInt(day ?? ''))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function simpleDateFormat(date: Date): string {
|
export function simpleDateFormat(date: Date): string {
|
||||||
return (
|
return (
|
||||||
date.getFullYear() +
|
date.getFullYear() +
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ export const VERSION = packageJson.version
|
|||||||
export const REPOSITORY = packageJson.repository
|
export const REPOSITORY = packageJson.repository
|
||||||
export const TITLE = import.meta.env.VITE_APP_TITLE
|
export const TITLE = import.meta.env.VITE_APP_TITLE
|
||||||
export const SIGNATURE = import.meta.env.VITE_APP_SIGNATURE
|
export const SIGNATURE = import.meta.env.VITE_APP_SIGNATURE
|
||||||
|
export const COPYRIGHT = import.meta.env.VITE_APP_COPYRIGHT
|
||||||
export const BASE_URL = import.meta.env.BASE_URL
|
export const BASE_URL = import.meta.env.BASE_URL
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { createApp } from 'vue'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
|
||||||
|
import ShaderviewElement from '@keithclark/shaderview';
|
||||||
|
customElements.define('kc-shaderview', ShaderviewElement);
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ const router = createRouter({
|
|||||||
history: createWebHistory(),
|
history: createWebHistory(),
|
||||||
routes: [
|
routes: [
|
||||||
{ path: '/', component: HomeView },
|
{ path: '/', component: HomeView },
|
||||||
{ path: '/articles/:year(\\d{4})/:month(\\d{2})/:day(\\d{2})/', component: ArticleView },
|
{ path: '/articles/:pathMatch(.*)/', component: ArticleView },
|
||||||
{ path: '/:pathMatch(.*)', component: NotFoundView },
|
{ path: '/:pathMatch(.*)', component: NotFoundView },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { ref, onBeforeMount } from 'vue'
|
|||||||
import { loadArticle } from '@lib/articles'
|
import { loadArticle } 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 NotFoundView from './NotFoundView.vue'
|
||||||
import { dateFromParts, simpleDateFormat } from '@lib/dates'
|
import { simpleDateFormat } from '@lib/dates'
|
||||||
import { SIGNATURE, TITLE } from '@lib/meta'
|
import { SIGNATURE, TITLE } from '@lib/meta'
|
||||||
import PageFooter from '@components/PageFooter.vue'
|
import PageFooter from '@components/PageFooter.vue'
|
||||||
import { stripHTML } from '@/lib/strings'
|
import { stripHTML } from '@/lib/strings'
|
||||||
@@ -15,13 +15,7 @@ const route = useRoute()
|
|||||||
|
|
||||||
async function loadPage(target: RouteLocation) {
|
async function loadPage(target: RouteLocation) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
article.value = await loadArticle(
|
article.value = await loadArticle(target.params.pathMatch as string)
|
||||||
dateFromParts(
|
|
||||||
target.params.year as string,
|
|
||||||
target.params.month as string,
|
|
||||||
target.params.day as string,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
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
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default ({ mode }: { mode: string }) => {
|
|||||||
process.env.VITE_APP_LANG = articlesConfig['lang']
|
process.env.VITE_APP_LANG = articlesConfig['lang']
|
||||||
process.env.VITE_APP_SIGNATURE = articlesConfig['signature']
|
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']
|
||||||
|
|
||||||
return defineConfig({
|
return defineConfig({
|
||||||
plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })],
|
plugins: [vue(), vueDevTools(), mdPlugin({ mode: [Mode.HTML] })],
|
||||||
|
|||||||
Reference in New Issue
Block a user