feat: page title
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
VITE_APP_TITLE=My Blog
|
||||
VITE_APP_SIGNATURE=By <b>me</b>
|
||||
VITE_APP_LANG=en
|
||||
@@ -37,3 +37,4 @@ __screenshots__/
|
||||
|
||||
# Vite
|
||||
*.timestamp-*-*.mjs
|
||||
.env
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 0,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "md-blog",
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="%VITE_APP_LANG%">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Blog</title>
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet" />
|
||||
<link rel="stylesheet" type="text/css" href="/articles/style.css" />
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { REPOSITORY, NAME, VERSION } from '@/lib/meta'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="$route.fullPath != '/'">
|
||||
<RouterLink to="/">Back to home</RouterLink>
|
||||
</template>
|
||||
<hr />
|
||||
<footer>
|
||||
<small>
|
||||
{{ new Date().getFullYear() }} - Made with <a :href="REPOSITORY">{{ NAME }}</a>
|
||||
{{ VERSION }}
|
||||
</small>
|
||||
</footer>
|
||||
</template>
|
||||
@@ -3,3 +3,5 @@ import packageJson from '@/../package.json'
|
||||
export const NAME = packageJson.name
|
||||
export const VERSION = packageJson.version
|
||||
export const REPOSITORY = packageJson.repository
|
||||
export const TITLE = import.meta.env.VITE_APP_TITLE
|
||||
export const SIGNATURE = import.meta.env.VITE_APP_SIGNATURE
|
||||
|
||||
@@ -5,10 +5,11 @@ import { loadArticle } from '@lib/articles'
|
||||
import { useRoute, onBeforeRouteUpdate, type RouteLocation } from 'vue-router'
|
||||
import NotFoundView from './NotFoundView.vue'
|
||||
import { dateFromParts, simpleDateFormat } from '@lib/dates'
|
||||
import { NAME, REPOSITORY, VERSION } from '@lib/meta'
|
||||
import { SIGNATURE, TITLE } from '@lib/meta'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
|
||||
const article = ref<Article | null>(null)
|
||||
const loading = ref<Boolean>(true)
|
||||
const loading = ref<boolean>(true)
|
||||
const route = useRoute()
|
||||
|
||||
async function loadPage(target: RouteLocation) {
|
||||
@@ -20,13 +21,10 @@ async function loadPage(target: RouteLocation) {
|
||||
target.params.day as string,
|
||||
),
|
||||
)
|
||||
window.document.title = TITLE + ' — ' + (article.value?.metadata.title ?? 'Not Found')
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function scrollTop() {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
|
||||
onBeforeMount(() => loadPage(route))
|
||||
onBeforeRouteUpdate(loadPage)
|
||||
</script>
|
||||
@@ -50,17 +48,9 @@ onBeforeRouteUpdate(loadPage)
|
||||
</div>
|
||||
<img id="thumbnail" :src="article.metadata.thumbnail" alt="thumbnail" />
|
||||
<div id="text" v-html="article.html"></div>
|
||||
<div id="signature">TODO signature</div>
|
||||
<div id="signature" v-html="SIGNATURE"></div>
|
||||
<br />
|
||||
<a @click.prevent="scrollTop" href="#">Go to top</a> -
|
||||
<RouterLink to="/">Back to home</RouterLink>
|
||||
<hr />
|
||||
<footer>
|
||||
<small>
|
||||
{{ new Date().getFullYear() }} - Made with <a :href="REPOSITORY">{{ NAME }}</a>
|
||||
{{ VERSION }}
|
||||
</small>
|
||||
</footer>
|
||||
<PageFooter />
|
||||
</main>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { listArticles } from '@lib/articles'
|
||||
import type { ArticleMetadata } from '@interfaces'
|
||||
import { simpleDateFormat } from '@/lib/dates'
|
||||
import { simpleDateFormat } from '@lib/dates'
|
||||
import { TITLE } from '@lib/meta'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
|
||||
const articles = ref<ArticleMetadata[]>([])
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const newArticles = await listArticles()
|
||||
console.log(newArticles)
|
||||
articles.value.splice(0, articles.value.length, ...newArticles)
|
||||
window.document.title = TITLE + ' — Home'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1 class="title">Articles</h1>
|
||||
<h1 class="title">{{ TITLE }}</h1>
|
||||
<template v-for="(metadata, index) in articles" v-bind:key="index">
|
||||
<div v-if="!metadata.draft && metadata.path" class="article">
|
||||
<RouterLink :to="metadata.path">
|
||||
@@ -27,5 +29,6 @@ onBeforeMount(async () => {
|
||||
</RouterLink>
|
||||
</div>
|
||||
</template>
|
||||
<PageFooter />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { TITLE } from '@/lib/meta'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { onBeforeMount } from 'vue'
|
||||
|
||||
onBeforeMount(() => {
|
||||
window.document.title = TITLE + ' — Not Found'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1>Page not found</h1>
|
||||
<RouterLink to="/">Back to home</RouterLink>
|
||||
<PageFooter />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@
|
||||
"@lib/*": ["./src/lib/*"],
|
||||
"@views/*": ["./src/views/*"],
|
||||
"@interfaces": ["./src/interfaces.ts"],
|
||||
"@articles/*": ["./articles/*"]
|
||||
"@articles/*": ["./articles/*"],
|
||||
"@components/*": ["./src/components/*"]
|
||||
},
|
||||
|
||||
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
||||
|
||||
@@ -15,6 +15,7 @@ export default defineConfig({
|
||||
'@lib': fileURLToPath(new URL('./src/lib', import.meta.url)),
|
||||
'@articles': fileURLToPath(new URL('./articles', import.meta.url)),
|
||||
'@interfaces': fileURLToPath(new URL('./src/interfaces.ts', import.meta.url)),
|
||||
'@components': fileURLToPath(new URL('./src/components', import.meta.url)),
|
||||
},
|
||||
},
|
||||
assetsInclude: [/\.\/articles\/.*(?!\.md)'/],
|
||||
|
||||
Reference in New Issue
Block a user