This commit is contained in:
14
lib/posts.ts
14
lib/posts.ts
@@ -1,4 +1,3 @@
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import matter from "gray-matter";
|
||||
@@ -9,13 +8,14 @@ const tagsFilePath = path.join(postsDirectory, "tags.json");
|
||||
type PostData = {
|
||||
id: string;
|
||||
href: string;
|
||||
venue: string;
|
||||
date: string;
|
||||
tags: string[];
|
||||
image: string | null;
|
||||
image: string | undefined;
|
||||
title?: string;
|
||||
excerpt?: string;
|
||||
video?: string;
|
||||
[key: string]: any;
|
||||
[key: string]: string | string[] | null | undefined;
|
||||
};
|
||||
|
||||
function getPostFilePaths(dir: string, fileList: string[] = []) {
|
||||
@@ -55,12 +55,14 @@ export function getSortedPostsData(category?: string): PostData[] {
|
||||
? matterResult.data.tags
|
||||
: matterResult.data.tags.split(/, ?/)
|
||||
: [];
|
||||
const venue = matterResult.data.venue ? matterResult.data.venue: "arxive";
|
||||
|
||||
let image = matterResult.data.teaser || matterResult.data.image || null;
|
||||
const image = matterResult.data.teaser || matterResult.data.image || null;
|
||||
|
||||
return {
|
||||
id,
|
||||
href,
|
||||
venue,
|
||||
date: matterResult.data.date ?? dateFromFileName,
|
||||
...matterResult.data,
|
||||
tags,
|
||||
@@ -77,8 +79,8 @@ export function getSortedPostsData(category?: string): PostData[] {
|
||||
});
|
||||
}
|
||||
|
||||
export function getAllTags(minCount: number = 1) {
|
||||
const allPosts = getSortedPostsData();
|
||||
export function getAllTags(minCount: number = 1, category?: "experience" | "research") {
|
||||
const allPosts = getSortedPostsData(category);
|
||||
const tags: { [tag: string]: number } = {};
|
||||
|
||||
allPosts.forEach((post) => {
|
||||
|
||||
Reference in New Issue
Block a user