Перенёс текст с главной страницы в файл Markdown
This commit is contained in:
parent
2024fa9f4b
commit
0643f48189
5 changed files with 95 additions and 83 deletions
|
|
@ -28,6 +28,13 @@ export async function fetchPostsSorted(postComparer?: PostComparer) {
|
|||
return sortedPosts;
|
||||
};
|
||||
|
||||
// rndtrash: пришлось заменить `path.parse`, так как на стороне клиента его больше не реализуют
|
||||
function getFilenameFromPath(path: string) {
|
||||
const file = path.split("/").pop();
|
||||
const dot = file?.lastIndexOf('.') ?? -1;
|
||||
return dot === -1 ? file : file?.substring(0, file.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
export async function fetchPosts() {
|
||||
const allPostFiles = import.meta.glob('/src/blogs/*.md');
|
||||
const iterablePostFiles = Object.entries(allPostFiles);
|
||||
|
|
@ -35,7 +42,7 @@ export async function fetchPosts() {
|
|||
const allPosts: App.BlogPost[] = await Promise.all(
|
||||
iterablePostFiles.map(async ([filePath, resolver]) => {
|
||||
const { metadata }: any = await resolver();
|
||||
const { name } = path.parse(filePath);
|
||||
const name = getFilenameFromPath(filePath);
|
||||
|
||||
return {
|
||||
slug: name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue