forked from pythonindia/inpycon2023
-
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.
feature to add dynamic content creation (pythonindia#170)
* remove pages, add flexibility to generate content for any folder.
- Loading branch information
Showing
23 changed files
with
499 additions
and
349 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
--- | ||
slug: faq | ||
title: Frequently Asked Questions | ||
--- | ||
|
||
### What is PyCon India? | ||
|
||
|
@@ -74,4 +78,4 @@ No. Each track is planned at its full capacity. | |
### Contact Us | ||
- For general queries: [[email protected]](mailto:[email protected]) | ||
- For ticket queries: [[email protected]](mailto:[email protected]) | ||
- Zulip Chat: [https://pyconindia.zulipchat.com/](https://pyconindia.zulipchat.com/) | ||
- Zulip Chat: [https://pyconindia.zulipchat.com/](https://pyconindia.zulipchat.com/) |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
import fs from "fs"; | ||
import { join } from "path"; | ||
import matter from "gray-matter"; | ||
|
||
export function getPostSlugs(directory) { | ||
const postsDirectory = join(process.cwd(), directory); | ||
return fs.readdirSync(postsDirectory); | ||
} | ||
|
||
export function getPostBySlug(postsDirectory, slug, fields = []) { | ||
const realSlug = slug.replace(/\.md$/, ""); | ||
const fullPath = join(postsDirectory, `${realSlug}.md`); | ||
const fileContents = fs.readFileSync(fullPath, "utf8"); | ||
const { data, content } = matter(fileContents); | ||
|
||
const items = {}; | ||
|
||
// Ensure only the minimal needed data is exposed | ||
fields.forEach((field) => { | ||
if (field === "slug") { | ||
items[field] = realSlug; | ||
} | ||
if (field === "content") { | ||
items[field] = content; | ||
} | ||
|
||
if (typeof data[field] !== "undefined") { | ||
items[field] = data[field]; | ||
} | ||
}); | ||
|
||
return items; | ||
} | ||
|
||
export function getAllPosts(postsDirectory, fields) { | ||
const slugs = getPostSlugs(postsDirectory); | ||
const posts = slugs.map((slug) => | ||
getPostBySlug(postsDirectory, slug, fields) | ||
); | ||
return posts; | ||
} |
Oops, something went wrong.