-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance publications management and update README documentation
- Added a new `publications/` directory to organize academic and professional publications in the project structure. - Implemented a function to fetch and display publications in the `Resume` component, enhancing the visibility of authored works. - Updated `site.config.ts` to include a new configuration option for the publications section headline. - Revised the README.md to provide clear instructions on how to add and format publications, including examples for markdown entries. - Improved overall documentation to support the new publications feature and ensure users can easily manage their publication entries.
- Loading branch information
1 parent
deaa4b6
commit 8b1975a
Showing
8 changed files
with
217 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { promises as fs } from "fs"; | ||
import path from "path"; | ||
import matter from "gray-matter"; | ||
|
||
export async function GET() { | ||
const publicationsDirectory = path.join( | ||
process.cwd(), | ||
"content/publications" | ||
); | ||
|
||
try { | ||
const files = await fs.readdir(publicationsDirectory); | ||
|
||
// Filter only markdown files and sort them by filename | ||
const publicationFiles = files | ||
.filter((file) => file.endsWith(".md")) | ||
.sort((a, b) => a.localeCompare(b)); | ||
|
||
const publications = await Promise.all( | ||
publicationFiles.map(async (filename) => { | ||
const filePath = path.join(publicationsDirectory, filename); | ||
const fileContent = await fs.readFile(filePath, "utf8"); | ||
const { data, content } = matter(fileContent); | ||
|
||
return { | ||
id: filename.replace(/\.md$/, ""), | ||
...data, | ||
content: content.trim(), | ||
}; | ||
}) | ||
); | ||
|
||
// Disable caching in development | ||
if (process.env.NODE_ENV === "development") { | ||
return new Response(JSON.stringify(publications), { | ||
headers: { | ||
"Cache-Control": "no-store, max-age=0", | ||
}, | ||
}); | ||
} | ||
|
||
return Response.json(publications); | ||
} catch (error) { | ||
// Return empty array if directory doesn't exist or other errors | ||
return Response.json([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: "Example Publication Title" | ||
authors: "John Doe, Jane Smith" | ||
venue: "International Journal of Computer Science" | ||
date: "2023-06" | ||
--- | ||
|
||
Brief description or abstract of the publication. Can include links to the full paper or DOI. | ||
|
||
- Key findings or contributions | ||
- Impact or significance | ||
- Additional relevant information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import matter from "gray-matter"; | ||
import { Publication } from "../types/publications"; | ||
|
||
const publicationsDirectory = path.join(process.cwd(), "content/publications"); | ||
|
||
export function getPublications(): Publication[] { | ||
// Check if directory exists | ||
if (!fs.existsSync(publicationsDirectory)) { | ||
return []; | ||
} | ||
|
||
const fileNames = fs.readdirSync(publicationsDirectory); | ||
const allPublications = fileNames.map((fileName) => { | ||
const id = fileName.replace(/\.md$/, ""); | ||
const fullPath = path.join(publicationsDirectory, fileName); | ||
const fileContents = fs.readFileSync(fullPath, "utf8"); | ||
const { data, content } = matter(fileContents); | ||
|
||
return { | ||
id, | ||
content, | ||
...data, | ||
} as Publication; | ||
}); | ||
|
||
return allPublications.sort((a, b) => { | ||
return new Date(b.date).getTime() - new Date(a.date).getTime(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface Publication { | ||
id: string; | ||
title: string; | ||
authors: string; | ||
venue: string; | ||
date: string; | ||
content: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters