Compare commits
2
Commits
4b02934a42
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bda17e292 | ||
|
|
029ced931d |
@@ -4,6 +4,7 @@ author: kleπek
|
|||||||
draft: false
|
draft: false
|
||||||
thumbnail: ./thumbnail.jpg
|
thumbnail: ./thumbnail.jpg
|
||||||
date: 2026-01-01
|
date: 2026-01-01
|
||||||
|
tags: sample
|
||||||
---
|
---
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"back_link": "<i icon=undo-2></i> Back to home",
|
"back_link": "<i icon=undo-2></i> Back to home",
|
||||||
"published_on": "Published on",
|
"published_on": "Published on",
|
||||||
"updated_on": "Updated on",
|
"updated_on": "Updated on",
|
||||||
|
"tags": "Tags:",
|
||||||
"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": "",
|
||||||
|
|||||||
@@ -185,3 +185,12 @@ nav .nav-items {
|
|||||||
.article-info {
|
.article-info {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.article-tag {
|
||||||
|
text-decoration: underline !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-active-tag {
|
||||||
|
text-decoration: underline !important;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "md-blog",
|
"name": "md-blog",
|
||||||
"version": "1.10.0",
|
"version": "1.11.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",
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ArticleMetadata } from "@/interfaces";
|
||||||
|
import { simpleDateFormat } from "@lib/dates";
|
||||||
|
import { PUBLISHED_ON } from "@lib/config";
|
||||||
|
import ArticleTagList from "@/components/ArticleTagList.vue";
|
||||||
|
|
||||||
|
defineProps<{ metadata: ArticleMetadata }>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<RouterLink :to="metadata.path" class="h-entry">
|
||||||
|
<h2 class="p-name" v-html="metadata.title"></h2>
|
||||||
|
<span class="article-info">
|
||||||
|
<span v-html="PUBLISHED_ON"></span>
|
||||||
|
 
|
||||||
|
<time class="dt-published" :datetime="simpleDateFormat(metadata.date)">
|
||||||
|
{{ simpleDateFormat(metadata.date) }}
|
||||||
|
</time>
|
||||||
|
<template v-if="metadata.tags.length > 0">
|
||||||
|
—
|
||||||
|
<article-tag-list :tags="metadata.tags" />
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
<img v-if="metadata.thumbnail" alt="thumbnail" :src="metadata.path + metadata.thumbnail" />
|
||||||
|
</RouterLink>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
defineProps<{ tag: string }>();
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<RouterLink :class="route.query.tag === tag ? 'article-active-tag' : 'article-tag'" :to="`/?tag=${tag}`">{{ tag }}</RouterLink>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { TAGS } from "@lib/config";
|
||||||
|
import ArticleTag from "@/components/ArticleTag.vue";
|
||||||
|
|
||||||
|
defineProps<{ tags: string[] }>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span v-html="TAGS"></span>
|
||||||
|
 
|
||||||
|
<template v-for="(tag, tagIndex) in tags" :key="tagIndex">
|
||||||
|
<template v-if="tagIndex > 0">, </template>
|
||||||
|
<article-tag :tag="tag" />
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
@@ -5,8 +5,15 @@ import { stripHTML } from '@lib/strings'
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<footer>
|
<footer>
|
||||||
{{ stripHTML(TITLE) }} © {{ new Date().getFullYear() }}, <span v-html="COPYRIGHT"></span>
|
{{ stripHTML(TITLE) }}
|
||||||
<span v-if="FOOTER"> | <span v-html="FOOTER"></span></span>
|
©
|
||||||
| Made with <a :href="REPOSITORY">{{ NAME }} {{ VERSION }}</a>
|
{{ new Date().getFullYear() }},
|
||||||
|
<span v-html="COPYRIGHT"></span>
|
||||||
|
<template v-if="FOOTER">
|
||||||
|
| 
|
||||||
|
<span v-html="FOOTER"></span>
|
||||||
|
 
|
||||||
|
</template>
|
||||||
|
| Made with <a :href="REPOSITORY">{{ NAME }} {{ VERSION }}</a>
|
||||||
</footer>
|
</footer>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface ArticleMetadata {
|
|||||||
author?: string
|
author?: string
|
||||||
thumbnail?: string
|
thumbnail?: string
|
||||||
draft?: boolean
|
draft?: boolean
|
||||||
|
tags: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Article {
|
export interface Article {
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ function parseMetadata(
|
|||||||
),
|
),
|
||||||
thumbnail: (srcAttributes.thumbnail as string | undefined) ?? "",
|
thumbnail: (srcAttributes.thumbnail as string | undefined) ?? "",
|
||||||
draft: draft,
|
draft: draft,
|
||||||
|
tags: (srcAttributes.tags as string | undefined ?? '')
|
||||||
|
.split(',')
|
||||||
|
.map((tag) => tag.trim())
|
||||||
|
.filter((tag) => tag !== ''),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ export const HOME_COUNT: number = articlesConfig.home_count;
|
|||||||
export const PUBLISHED_ON: string = articlesConfig.published_on;
|
export const PUBLISHED_ON: string = articlesConfig.published_on;
|
||||||
export const UPDATED_ON: string = articlesConfig.updated_on;
|
export const UPDATED_ON: string = articlesConfig.updated_on;
|
||||||
export const AUTHORED: string = articlesConfig.authored;
|
export const AUTHORED: string = articlesConfig.authored;
|
||||||
|
export const TAGS: string = articlesConfig.tags;
|
||||||
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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { AUTHORED, PUBLISHED_ON, SIGNATURE, TITLE, UPDATED_ON } from '@lib/confi
|
|||||||
import { stripHTML } from '@lib/strings'
|
import { stripHTML } from '@lib/strings'
|
||||||
import BackHomeButton from '@components/BackHomeButton.vue'
|
import BackHomeButton from '@components/BackHomeButton.vue'
|
||||||
import NotFoundView from '@views/NotFoundView.vue'
|
import NotFoundView from '@views/NotFoundView.vue'
|
||||||
|
import ArticleTagList from '@components/ArticleTagList.vue'
|
||||||
|
|
||||||
const article = ref<Article | null>(null)
|
const article = ref<Article | null>(null)
|
||||||
const loading = ref<boolean>(true)
|
const loading = ref<boolean>(true)
|
||||||
@@ -37,14 +38,26 @@ onUpdated(updateDynamicContent)
|
|||||||
<div class="article-header">
|
<div class="article-header">
|
||||||
<h1 class="article-title p-name" v-html="article.metadata.title"></h1>
|
<h1 class="article-title p-name" v-html="article.metadata.title"></h1>
|
||||||
<div class="article-info">
|
<div class="article-info">
|
||||||
<span v-if="article.metadata.author"
|
<template v-if="article.metadata.author">
|
||||||
><span v-html="AUTHORED"></span> <span class="p-author h-card" v-html="article.metadata.author"></span> —
|
<span v-html="AUTHORED"></span>
|
||||||
</span>
|
 
|
||||||
<span v-html="PUBLISHED_ON"></span> <time class="dt-published" :datetime="simpleDateFormat(article.metadata.date)">{{ simpleDateFormat(article.metadata.date) }}</time>
|
<span class="p-author h-card" v-html="article.metadata.author"></span>
|
||||||
<span v-if="article.metadata.updated"
|
 —
|
||||||
>— <span v-html="UPDATED_ON"></span>
|
</template>
|
||||||
{{ simpleDateFormat(article.metadata.updated) }}</span
|
<span v-html="PUBLISHED_ON"></span>
|
||||||
>
|
 
|
||||||
|
<time class="dt-published" :datetime="simpleDateFormat(article.metadata.date)">
|
||||||
|
{{ simpleDateFormat(article.metadata.date) }}
|
||||||
|
</time>
|
||||||
|
<template v-if="article.metadata.updated">
|
||||||
|
 —
|
||||||
|
<span v-html="UPDATED_ON"></span>
|
||||||
|
{{ simpleDateFormat(article.metadata.updated) }}
|
||||||
|
</template>
|
||||||
|
<template v-if="article.metadata.tags.length > 0">
|
||||||
|
—
|
||||||
|
<article-tag-list :tags="article.metadata.tags" />
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
v-if="article.metadata.thumbnail"
|
v-if="article.metadata.thumbnail"
|
||||||
|
|||||||
+35
-27
@@ -1,42 +1,50 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onBeforeMount, onUpdated, onMounted } from 'vue'
|
import { ref, onBeforeMount, onUpdated, onMounted, watch } from "vue";
|
||||||
import { listArticles, updateDynamicContent } 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 { HOME_COUNT, PROD, TITLE } from "@lib/config";
|
||||||
import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config'
|
import { stripHTML } from "@lib/strings";
|
||||||
import { stripHTML } from '@lib/strings'
|
import ArticleItem from "@/components/ArticleItem.vue";
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const articles = ref<ArticleMetadata[]>([])
|
const articles = ref<ArticleMetadata[]>([]);
|
||||||
const loading = ref<boolean>(true)
|
const filteredArticles = ref<ArticleMetadata[]>([]);
|
||||||
|
const loading = ref<boolean>(true);
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
function filterArticles() {
|
||||||
|
if (route.query.tag) {
|
||||||
|
filteredArticles.value = articles.value
|
||||||
|
.filter((metadata) => metadata.tags.includes(route.query.tag as string));
|
||||||
|
} else {
|
||||||
|
filteredArticles.value = articles.value
|
||||||
|
.slice(0, HOME_COUNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
const newArticles = (await listArticles())
|
const newArticles = (await listArticles())
|
||||||
.filter((metadata) => (!metadata.draft || !PROD) && metadata.path)
|
.filter((metadata) => (!metadata.draft || !PROD) && metadata.path)
|
||||||
.slice(0, HOME_COUNT)
|
articles.value.splice(0, articles.value.length, ...newArticles);
|
||||||
articles.value.splice(0, articles.value.length, ...newArticles)
|
filterArticles();
|
||||||
window.document.title = stripHTML(TITLE) + ' — Home'
|
window.document.title = stripHTML(TITLE) + " — Home";
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
await updateDynamicContent()
|
await updateDynamicContent();
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => route.query.tag, () => {
|
||||||
|
filterArticles();
|
||||||
})
|
})
|
||||||
onMounted(updateDynamicContent)
|
|
||||||
onUpdated(updateDynamicContent)
|
onMounted(updateDynamicContent);
|
||||||
|
onUpdated(updateDynamicContent);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="!loading" class="home">
|
<div v-if="!loading" class="home">
|
||||||
<template v-for="(metadata, index) in articles" :key="index">
|
<template v-for="(metadata, index) in filteredArticles" :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" class="h-entry">
|
<article-item :metadata="metadata" />
|
||||||
<h2 class="p-name" v-html="metadata.title"></h2>
|
|
||||||
<span class="article-info"
|
|
||||||
><span v-html="PUBLISHED_ON"></span> <time class="dt-published" :datetime="simpleDateFormat(metadata.date)">{{ simpleDateFormat(metadata.date) }}</time></span
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
v-if="metadata.thumbnail"
|
|
||||||
alt="thumbnail"
|
|
||||||
:src="metadata.path + metadata.thumbnail"
|
|
||||||
/>
|
|
||||||
</RouterLink>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user