mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 18:39:14 +03:00
added support for draft markdowns
This commit is contained in:
parent
64ab0c58cd
commit
56d16d7bf3
@ -48,7 +48,6 @@ const SearchInput: Component<SearchInputProps> = (props) => {
|
|||||||
resetSearch();
|
resetSearch();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(param);
|
|
||||||
|
|
||||||
setSearch(param);
|
setSearch(param);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function formatArticlesByLangs(data: Record<string, MDXInstance<ArticleTy
|
|||||||
const name = splitted.at(-3);
|
const name = splitted.at(-3);
|
||||||
|
|
||||||
if (!modules[name]) modules[name] = {};
|
if (!modules[name]) modules[name] = {};
|
||||||
modules[name][lang] = module;
|
if (!module.frontmatter.draft) modules[name][lang] = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
|
|||||||
@ -21,14 +21,16 @@ export async function getStaticPaths() {
|
|||||||
const entries = Object.keys(modules).map((key) => [key, key.split("/").slice(6)[0]]);
|
const entries = Object.keys(modules).map((key) => [key, key.split("/").slice(6)[0]]);
|
||||||
const formatted = formatArticlesByLangs(modules);
|
const formatted = formatArticlesByLangs(modules);
|
||||||
|
|
||||||
return entries.map(([key, lang]) => {
|
return entries
|
||||||
const article = modules[key];
|
.map(([key, lang]) => {
|
||||||
const dirName = key.split("/").at(-3);
|
const article = modules[key];
|
||||||
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
const dirName = key.split("/").at(-3);
|
||||||
const slug = `${lang !== DEFAULT_LANGUAGE ? `${lang}/` : ""}blog/${published_at}/${article.frontmatter.slug}`;
|
const published_at = new Date(article.frontmatter.published_at).toLocaleDateString("en-CA");
|
||||||
|
const slug = `${lang !== DEFAULT_LANGUAGE ? `${lang}/` : ""}blog/${published_at}/${article.frontmatter.slug}`;
|
||||||
|
|
||||||
return { params: { slug }, props: { article, alternateLangs: Object.keys(formatted[dirName]) } };
|
return { params: { slug }, props: { article, alternateLangs: Object.keys(formatted[dirName]) } };
|
||||||
});
|
})
|
||||||
|
.filter(({ props: { article } }) => !article.frontmatter.draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class ArticleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return articles;
|
return articles.filter((article) => !article.frontmatter.draft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
src/types/main.d.ts
vendored
1
src/types/main.d.ts
vendored
@ -39,6 +39,7 @@ declare global {
|
|||||||
tags: Array<string>;
|
tags: Array<string>;
|
||||||
published_at: string;
|
published_at: string;
|
||||||
lang?: string;
|
lang?: string;
|
||||||
|
draft?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProjectType = {
|
type ProjectType = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user