Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b02934a42 | ||
|
|
a7fba1897b | ||
|
|
b13bb738ce |
@@ -5,6 +5,7 @@
|
|||||||
"lang": "en",
|
"lang": "en",
|
||||||
"custom_head": "",
|
"custom_head": "",
|
||||||
"home_count": 5,
|
"home_count": 5,
|
||||||
|
"archive_link": "<i icon=archive></i> ARCHIVE",
|
||||||
"rss_link": "<i icon=rss></i> RSS",
|
"rss_link": "<i icon=rss></i> RSS",
|
||||||
"about_link": "<i icon=info></i> ABOUT",
|
"about_link": "<i icon=info></i> ABOUT",
|
||||||
"back_link": "<i icon=undo-2></i> Back to home",
|
"back_link": "<i icon=undo-2></i> Back to home",
|
||||||
@@ -12,5 +13,6 @@
|
|||||||
"updated_on": "Updated on",
|
"updated_on": "Updated on",
|
||||||
"authored": "By",
|
"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>",
|
"copyright": "<a style=\"text-decoration:none;color:inherit;\" target=_blank href=\"https://creativecommons.org/licenses/by-nc/4.0/\">CC BY-NC</a>",
|
||||||
"footer": ""
|
"footer": "",
|
||||||
|
"favicon_ico": ""
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,10 +2,10 @@
|
|||||||
<html lang="%VITE_APP_LANG%">
|
<html lang="%VITE_APP_LANG%">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="@articles/favicon.ico" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
||||||
<title>%VITE_APP_TITLE_NO_HTML%</title>
|
<title>%VITE_APP_TITLE_NO_HTML%</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/src/style.scss" />
|
<link rel="stylesheet" type="text/css" href="/src/style.scss" />
|
||||||
|
<link rel='shortcut icon' href='/favicon.ico' />
|
||||||
<meta property="og:url" content="%VITE_BASE_URL%" />
|
<meta property="og:url" content="%VITE_BASE_URL%" />
|
||||||
<meta property="og:title" content="%VITE_APP_TITLE_NO_HTML%" />
|
<meta property="og:title" content="%VITE_APP_TITLE_NO_HTML%" />
|
||||||
<link rel="alternate" href="%VITE_BASE_URL%/rss.xml" type="application/rss+xml" title="RSS 2.0" />
|
<link rel="alternate" href="%VITE_BASE_URL%/rss.xml" type="application/rss+xml" title="RSS 2.0" />
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "md-blog",
|
"name": "md-blog",
|
||||||
"version": "1.9.4",
|
"version": "1.10.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": "https://git.klemek.fr/klemek/md-blog",
|
"repository": "https://git.klemek.fr/klemek/md-blog",
|
||||||
|
|||||||
+10
-17
@@ -37,10 +37,7 @@ function readArticleMetadata(path: string): Record<string, string> | null {
|
|||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatArticlePage(
|
function formatArticlePage(metadata: Record<string, string>, baseHtml: string): string {
|
||||||
metadata: Record<string, string>,
|
|
||||||
baseHtml: string,
|
|
||||||
): string {
|
|
||||||
let outHtml = baseHtml;
|
let outHtml = baseHtml;
|
||||||
outHtml = outHtml.replace(/<.*?property="og:url".*?>/gm, "");
|
outHtml = outHtml.replace(/<.*?property="og:url".*?>/gm, "");
|
||||||
outHtml = outHtml.replace(
|
outHtml = outHtml.replace(
|
||||||
@@ -50,10 +47,7 @@ function formatArticlePage(
|
|||||||
const blog_title = articlesConfig.title.replace(/(<([^>]+)>)/gi, "").trim();
|
const blog_title = articlesConfig.title.replace(/(<([^>]+)>)/gi, "").trim();
|
||||||
if (metadata.title) {
|
if (metadata.title) {
|
||||||
const title = metadata.title.replace(/(<([^>]+)>)/gi, "").trim();
|
const title = metadata.title.replace(/(<([^>]+)>)/gi, "").trim();
|
||||||
outHtml = outHtml.replace(
|
outHtml = outHtml.replace(/<title>.*?<\/title>/gm, `<title>${blog_title} — ${title}</title>`);
|
||||||
/<title>.*?<\/title>/gm,
|
|
||||||
`<title>${blog_title} — ${title}</title>`,
|
|
||||||
);
|
|
||||||
outHtml = outHtml.replace(/<.*?property="og:title".*?>/gm, "");
|
outHtml = outHtml.replace(/<.*?property="og:title".*?>/gm, "");
|
||||||
outHtml = outHtml.replace(
|
outHtml = outHtml.replace(
|
||||||
/<\/head>/gm,
|
/<\/head>/gm,
|
||||||
@@ -82,10 +76,7 @@ function addFeedArticle(metadata: Record<string, string>, feed: Feed) {
|
|||||||
id: metadata.path,
|
id: metadata.path,
|
||||||
link: `${articlesConfig.base_url}${metadata.path}/`,
|
link: `${articlesConfig.base_url}${metadata.path}/`,
|
||||||
date: new Date(Date.parse(metadata.date)),
|
date: new Date(Date.parse(metadata.date)),
|
||||||
image: metadata.thumbnail.replace(
|
image: metadata.thumbnail.replace("./", articlesConfig.base_url + metadata.path + "/"),
|
||||||
"./",
|
|
||||||
articlesConfig.base_url + metadata.path + "/",
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +98,7 @@ const feed = new Feed({
|
|||||||
id: articlesConfig.base_url,
|
id: articlesConfig.base_url,
|
||||||
link: articlesConfig.base_url,
|
link: articlesConfig.base_url,
|
||||||
language: articlesConfig.lang,
|
language: articlesConfig.lang,
|
||||||
favicon: articlesConfig.base_url + "articles/favicon.ico",
|
favicon: articlesConfig.base_url + "/favicon.ico",
|
||||||
generator: "md-blog",
|
generator: "md-blog",
|
||||||
feedLinks: {
|
feedLinks: {
|
||||||
json: articlesConfig.base_url + "feed.json",
|
json: articlesConfig.base_url + "feed.json",
|
||||||
@@ -125,10 +116,7 @@ const feed = new Feed({
|
|||||||
});
|
});
|
||||||
|
|
||||||
metadatas.forEach((metadata) => {
|
metadatas.forEach((metadata) => {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(`dist/${metadata.path}/index.html`, formatArticlePage(metadata, indexContent));
|
||||||
`dist/${metadata.path}/index.html`,
|
|
||||||
formatArticlePage(metadata, indexContent),
|
|
||||||
);
|
|
||||||
console.info(`Wrote dist/${metadata.path}/index.html`);
|
console.info(`Wrote dist/${metadata.path}/index.html`);
|
||||||
addFeedArticle(metadata, feed);
|
addFeedArticle(metadata, feed);
|
||||||
});
|
});
|
||||||
@@ -139,3 +127,8 @@ fs.writeFileSync("dist/atom.xml", feed.atom1());
|
|||||||
console.info(`Wrote dist/atom.xml`);
|
console.info(`Wrote dist/atom.xml`);
|
||||||
fs.writeFileSync("dist/rss.xml", feed.rss2());
|
fs.writeFileSync("dist/rss.xml", feed.rss2());
|
||||||
console.info(`Wrote dist/rss.xml`);
|
console.info(`Wrote dist/rss.xml`);
|
||||||
|
|
||||||
|
if (articlesConfig.favicon_ico) {
|
||||||
|
fs.copyFileSync(`articles/${articlesConfig.favicon_ico}`, "dist/favicon.ico");
|
||||||
|
console.info(`Wrote dist/favicon.ico`);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { BASE_URL, TITLE, RSS_LINK, ABOUT_LINK } from '@lib/config'
|
import { BASE_URL, TITLE, RSS_LINK, ABOUT_LINK, ARCHIVE_LINK } from '@lib/config'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -7,6 +7,7 @@ import { BASE_URL, TITLE, RSS_LINK, ABOUT_LINK } from '@lib/config'
|
|||||||
<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>
|
<RouterLink to="/about/"><span v-html="ABOUT_LINK"></span></RouterLink>
|
||||||
|
<RouterLink to="/archive/"><span v-html="ARCHIVE_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>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export const COPYRIGHT: string = articlesConfig.copyright;
|
|||||||
export const FOOTER: string = articlesConfig.footer;
|
export const FOOTER: string = articlesConfig.footer;
|
||||||
export const RSS_LINK: string = articlesConfig.rss_link;
|
export const RSS_LINK: string = articlesConfig.rss_link;
|
||||||
export const BACK_LINK: string = articlesConfig.back_link;
|
export const BACK_LINK: string = articlesConfig.back_link;
|
||||||
|
export const ARCHIVE_LINK: string = articlesConfig.archive_link;
|
||||||
export const ABOUT_LINK: string = articlesConfig.about_link;
|
export const ABOUT_LINK: string = articlesConfig.about_link;
|
||||||
export const HOME_COUNT: number = articlesConfig.home_count;
|
export const HOME_COUNT: number = articlesConfig.home_count;
|
||||||
export const PUBLISHED_ON: string = articlesConfig.published_on;
|
export const PUBLISHED_ON: string = articlesConfig.published_on;
|
||||||
|
|||||||
+13
-11
@@ -1,17 +1,19 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
import HomeView from '@views/HomeView.vue'
|
import HomeView from "@views/HomeView.vue";
|
||||||
import AboutView from '@views/AboutView.vue'
|
import ArchiveView from "@views/ArchiveView.vue";
|
||||||
import ArticleView from '@views/ArticleView.vue'
|
import AboutView from "@views/AboutView.vue";
|
||||||
import NotFoundView from '@views/NotFoundView.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: "/archive/", component: ArchiveView },
|
||||||
{ path: '/articles/:pathMatch(.*)/', component: ArticleView },
|
{ path: "/about/", component: AboutView },
|
||||||
{ path: '/:pathMatch(.*)', component: NotFoundView },
|
{ path: "/articles/:pathMatch(.*)/", component: ArticleView },
|
||||||
|
{ path: "/:pathMatch(.*)", component: NotFoundView },
|
||||||
],
|
],
|
||||||
})
|
});
|
||||||
|
|
||||||
export default router
|
export default router;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
|
||||||
|
import { listArticles, updateDynamicContent } from '@lib/articles'
|
||||||
|
import type { ArticleMetadata } from '@interfaces'
|
||||||
|
import { simpleDateFormat } from '@lib/dates'
|
||||||
|
import { PROD, TITLE } from '@lib/config'
|
||||||
|
import { stripHTML } from '@lib/strings'
|
||||||
|
|
||||||
|
const articles = ref<ArticleMetadata[]>([])
|
||||||
|
const loading = ref<boolean>(true)
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
const newArticles = (await listArticles())
|
||||||
|
.filter((metadata) => (!metadata.draft || !PROD) && metadata.path)
|
||||||
|
articles.value.splice(0, articles.value.length, ...newArticles)
|
||||||
|
window.document.title = stripHTML(TITLE) + ' — Archive'
|
||||||
|
loading.value = false
|
||||||
|
await updateDynamicContent()
|
||||||
|
})
|
||||||
|
onMounted(updateDynamicContent)
|
||||||
|
onUpdated(updateDynamicContent)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="!loading" class="home">
|
||||||
|
<ul>
|
||||||
|
<li v-for="(metadata, index) in articles" :key="index">
|
||||||
|
<div v-if="(!metadata.draft || !PROD) && metadata.path" class="article-item">
|
||||||
|
<time class="dt-published mono" :datetime="simpleDateFormat(metadata.date)">{{ simpleDateFormat(metadata.date) }}</time>
|
||||||
|
|
||||||
|
<RouterLink :to="metadata.path" class="h-entry">
|
||||||
|
<span class="p-name" v-html="metadata.title"></span>
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user