Compare commits

..

1 Commits

Author SHA1 Message Date
Riyyi 090af8aa68 test 2 months ago
  1. 1
      content.config.ts
  2. 7
      content/articles/first.md
  3. 7
      content/articles/personal-website.md
  4. 5
      content/articles/second.md
  5. 1
      src/pages/articles/[slug].vue
  6. 13
      src/pages/articles/index.vue
  7. 24
      src/utils/index.ts

1
content.config.ts

@ -11,6 +11,7 @@ export default defineContentConfig({
schema: z.object({ schema: z.object({
date: z.date(), date: z.date(),
img: z.string(), img: z.string(),
sub: z.string(),
tags: z.array(z.string()), tags: z.array(z.string()),
}) })
}) })

7
content/articles/first.md

@ -2,12 +2,9 @@
title: "My First Blog Post" title: "My First Blog Post"
description: "This is a test article." description: "This is a test article."
navigation: true navigation: true
date: "2025-03-01" sub: "C++20, GLSL, Lua"
img: "/img/personal-website/login.png" img: "/img/personal-website/login.png"
tags: date: "2025-03-01"
- C++20
- GLSL
- Lua
--- ---
Foobarbazbuz. Foobarbazbuz.

7
content/articles/personal-website.md

@ -2,12 +2,9 @@
title: "Personal Website" title: "Personal Website"
description: "An open-source content management system, used for this website." description: "An open-source content management system, used for this website."
navigation: false navigation: false
date: "2025-03-03" sub: "PHP 7, MySQL, jQuery"
img: "/img/personal-website/admin-menu.png" img: "/img/personal-website/admin-menu.png"
tags: date: "2025-03-03"
- PHP 7
- MySQL
- jQuery
--- ---
<small>Open-source content management system.<br> <small>Open-source content management system.<br>

5
content/articles/second.md

@ -2,10 +2,9 @@
title: "My Second Blog Post" title: "My Second Blog Post"
description: "This is another article." description: "This is another article."
navigation: false navigation: false
date: "2025-03-02" sub: "Bash"
img: "/img/personal-website/reset-password.png" img: "/img/personal-website/reset-password.png"
tags: date: "2025-03-02"
- Bash
--- ---
This is another article. This is another article.

1
src/pages/articles/[slug].vue

@ -4,7 +4,6 @@
<ArticlesTableOfContents v-if="article.navigation" :toc="article.body.toc" /> <ArticlesTableOfContents v-if="article.navigation" :toc="article.body.toc" />
<h1>{{ article.title }}</h1> <h1>{{ article.title }}</h1>
<p><i><small>{{ prettyDate(article.date) }}</small></i></p>
<ContentRenderer :value="article" /> <ContentRenderer :value="article" />
</template> </template>
<template v-else> <template v-else>

13
src/pages/articles/index.vue

@ -10,13 +10,10 @@
</div> </div>
<div class="col-7 col-lg-8 col-xl-9"> <div class="col-7 col-lg-8 col-xl-9">
<NuxtLink v-if="article.img" :to="article.path"> <NuxtLink v-if="article.img" :to="article.path">
<h4 class="mb-0"><strong>{{ article.title }}</strong></h4> <h4><strong>{{ article.title }}</strong></h4>
</NuxtLink> </NuxtLink>
<p><i><small>{{ prettyDate(article.date) }}</small></i></p> {{ article.description }}<br>
<p>{{ article.description }}</p> <i><small>{{ article.sub }}</small></i>
<template v-if="article.tags">
<p>Tags: <code>{{ article.tags.join(", ") }}</code></p>
</template>
</div> </div>
</div> </div>
@ -41,10 +38,6 @@ a h4 {
a h4:hover { a h4:hover {
color: var(--bs-link-hover-color); color: var(--bs-link-hover-color);
} }
code {
color: var(--bs-link-color);
}
</style> </style>
<script setup lang="ts"> <script setup lang="ts">

24
src/utils/index.ts

@ -1,14 +1,8 @@
import { withTrailingSlash, withLeadingSlash, joinURL } from "ufo" import { withTrailingSlash, withLeadingSlash, joinURL } from "ufo"
import { useRuntimeConfig } from "#imports" import { useRuntimeConfig } from "#imports"
/**
* Returns if environment is in development mode
*/
export const isDev = process.env.NODE_ENV === "development"; export const isDev = process.env.NODE_ENV === "development";
/**
* Gets URL path, taking into acount the baseURL
*/
export const getPublicPath = function (path: string): string { export const getPublicPath = function (path: string): string {
if (path?.startsWith("/") && !path.startsWith("//")) { if (path?.startsWith("/") && !path.startsWith("//")) {
const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL)); const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL));
@ -16,23 +10,7 @@ export const getPublicPath = function (path: string): string {
return joinURL(_base, path); return joinURL(_base, path);
} }
} }
return path; return path;
} }
/** // datetime format
* Return date string in format "Feb 10, 2025"
*/
export const prettyDate = function (date: string | Date): string {
if (typeof date === "string") {
date = new Date(date);
}
const formatted = new Intl.DateTimeFormat("en-US", {
month: "short",
day: "numeric",
year: "numeric"
}).format(date);
return formatted;
}

Loading…
Cancel
Save