mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-29 18:00:26 -06:00
* add formbricks website with blog and docs Co-authored-by: knugget <johannes@knugget.de>
22 lines
638 B
TypeScript
22 lines
638 B
TypeScript
import glob from "fast-glob";
|
|
import * as path from "path";
|
|
|
|
async function importArticle(articleFilename: string) {
|
|
let { meta, default: component } = await import(`../pages/blog/${articleFilename}`);
|
|
return {
|
|
slug: articleFilename.replace(/(\/index)?\.mdx$/, ""),
|
|
...meta,
|
|
component,
|
|
};
|
|
}
|
|
|
|
export async function getAllArticles() {
|
|
let articleFilenames = await glob(["*.mdx", "*/index.mdx"], {
|
|
cwd: path.join(process.cwd(), "pages/blog"),
|
|
});
|
|
|
|
let articles = await Promise.all(articleFilenames.map(importArticle));
|
|
|
|
return articles.sort((a, z) => new Date(z.date).valueOf() - new Date(a.date).valueOf());
|
|
}
|