From bf88315469d9eb7ba24e2fef6e3081db68b42cc5 Mon Sep 17 00:00:00 2001 From: dallyh Date: Tue, 20 Feb 2024 00:03:13 +0100 Subject: [PATCH] WIP: Cleanup --- package-lock.json | 3 + .../astro/blog/BlogPostPreview.astro | 4 +- src/components/astro/blog/Category.astro | 16 +- src/components/astro/blog/FeaturedPosts.astro | 14 +- src/components/astro/blog/RecentPosts.astro | 14 +- .../astro/blog/SmallBlogPostPreview.astro | 4 +- src/components/astro/blog/Tag.astro | 17 +- src/components/astro/blog/TagList.astro | 2 +- .../astro/global/HeadHrefLangs.astro | 3 +- .../astro/global/LanguageSelector.astro | 3 +- .../astro/projects/ProjectCard.astro | 2 +- src/content/categories/guides.yaml | 2 +- src/content/categories/lifestyle.yaml | 8 + src/content/categories/software.yaml | 8 + .../posts/cs/2023-01-01-typography-example.md | 10 +- .../cs/2023-12-29-localized-slug-title.md | 14 ++ .../cs/2024-01-02-test-post-from-identity.md | 15 ++ .../posts/cs/2024-01-07-test-post-from-cms.md | 17 ++ ...024-01-13-test-post-with-external-image.md | 17 ++ src/content/posts/cs/post-2.md | 153 +++++++++++++++++ src/content/posts/cs/post-3.md | 157 +++++++++++++++++ src/content/posts/cs/post-4.md | 138 +++++++++++++++ .../posts/en/2023-01-01-typography-example.md | 10 +- .../en/2023-12-29-localized-slug-title.md | 14 ++ .../en/2024-01-02-test-post-from-identity.md | 15 ++ .../posts/en/2024-01-07-test-post-from-cms.md | 17 ++ ...024-01-13-test-post-with-external-image.md | 17 ++ src/content/posts/en/post-2.md | 153 +++++++++++++++++ src/content/posts/en/post-3.md | 157 +++++++++++++++++ src/content/posts/en/post-4.md | 158 ++++++++++++++++++ src/content/project-tags/astrojs.json | 2 +- src/content/project-tags/javascript.json | 2 +- src/content/project-tags/kmp.json | 2 +- src/content/project-tags/react.json | 2 +- src/content/project-tags/typescript.json | 2 +- src/content/project-tags/web.json | 2 +- .../github-oauth-provider-for-static-cms.md | 9 +- .../projects/cs/lemmy-kotlin-client.md | 5 +- src/content/projects/cs/this-web.md | 13 +- .../github-oauth-provider-for-static-cms.md | 9 +- .../projects/en/lemmy-kotlin-client.md | 5 +- src/content/projects/en/this-web.md | 11 +- src/content/tags/community.yaml | 4 + src/content/tags/successes.yaml | 4 + src/i18n/utils.ts | 2 +- src/layouts/BlogPostLayout.astro | 6 +- src/layouts/PostsLayout.astro | 2 - .../blog/categories/[...category].astro | 43 +---- .../[...lang]/blog/posts/[...page].astro | 25 ++- .../blog/posts/[...slug]/index.astro | 26 +-- .../blog/posts/[...slug]/index.png.ts | 3 +- .../[...lang]/blog/posts/featured/index.astro | 2 +- src/pages/[...lang]/blog/tags/[...tag].astro | 52 ++---- src/pages/[...lang]/blog/tags/index.astro | 2 +- src/pages/[...lang]/og.png.ts | 2 +- src/utils/getFilteredPostsCollection.ts | 68 ++++++++ src/utils/index.ts | 13 ++ tsconfig.json | 2 +- 58 files changed, 1260 insertions(+), 222 deletions(-) create mode 100644 src/content/categories/lifestyle.yaml create mode 100644 src/content/categories/software.yaml create mode 100644 src/content/posts/cs/2023-12-29-localized-slug-title.md create mode 100644 src/content/posts/cs/2024-01-02-test-post-from-identity.md create mode 100644 src/content/posts/cs/2024-01-07-test-post-from-cms.md create mode 100644 src/content/posts/cs/2024-01-13-test-post-with-external-image.md create mode 100644 src/content/posts/cs/post-2.md create mode 100644 src/content/posts/cs/post-3.md create mode 100644 src/content/posts/cs/post-4.md create mode 100644 src/content/posts/en/2023-12-29-localized-slug-title.md create mode 100644 src/content/posts/en/2024-01-02-test-post-from-identity.md create mode 100644 src/content/posts/en/2024-01-07-test-post-from-cms.md create mode 100644 src/content/posts/en/2024-01-13-test-post-with-external-image.md create mode 100644 src/content/posts/en/post-2.md create mode 100644 src/content/posts/en/post-3.md create mode 100644 src/content/posts/en/post-4.md create mode 100644 src/content/tags/community.yaml create mode 100644 src/content/tags/successes.yaml create mode 100644 src/utils/getFilteredPostsCollection.ts create mode 100644 src/utils/index.ts diff --git a/package-lock.json b/package-lock.json index 5229b7c..6b6ada9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20481,6 +20481,9 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } + }, + "src/utils": { + "extraneous": true } } } diff --git a/src/components/astro/blog/BlogPostPreview.astro b/src/components/astro/blog/BlogPostPreview.astro index bb3d899..7fd1f57 100644 --- a/src/components/astro/blog/BlogPostPreview.astro +++ b/src/components/astro/blog/BlogPostPreview.astro @@ -2,9 +2,7 @@ import FormattedDate from "@components/astro/blog/FormattedDate.astro"; import { loadNamespaces, t } from "@i18n/i18n"; import { getLocale } from "@i18n/utils"; -import { getBlogPostUrl } from "@utils/getBlogPostUrl"; -import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale"; -import { getOgImageUrl } from "@utils/getOgImageUrl"; +import { getBlogPostUrl, getCategoryTitleByLocale, getOgImageUrl } from "@utils"; import type { CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; import TagList from "./TagList.astro"; diff --git a/src/components/astro/blog/Category.astro b/src/components/astro/blog/Category.astro index fcf6c3e..0ececa1 100644 --- a/src/components/astro/blog/Category.astro +++ b/src/components/astro/blog/Category.astro @@ -1,7 +1,7 @@ --- import { loadNamespaces, t } from "@i18n/i18n"; import { getLocale } from "@i18n/utils"; -import { getCategoryDescriptionByLocale, getCategoryTitleByLocale } from "@utils/getCategoryByLocale"; +import { getCategoryDescriptionByLocale, getCategoryTitleByLocale, getFilteredPostsCollection } from "@utils"; import { Icon } from "astro-icon/components"; import { getCollection, type CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; @@ -19,19 +19,7 @@ const title = await getCategoryTitleByLocale(locale, category.id); const description = await getCategoryDescriptionByLocale(locale, category.id); const url = getRelativeLocaleUrl(locale, `/blog/categories/${category.id}`); -const categoryPosts = await getCollection("posts", ({ data }) => { - return !data.hidden && data.language === locale && data.category?.id === category.id; -}); - -// Only last 3 recent -const filteredPosts = - categoryPosts === undefined - ? undefined - : categoryPosts - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }) - .slice(0, 3); +const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, categoryId: category.id}); ---
  • diff --git a/src/components/astro/blog/FeaturedPosts.astro b/src/components/astro/blog/FeaturedPosts.astro index 3c99dd1..2b92cb5 100644 --- a/src/components/astro/blog/FeaturedPosts.astro +++ b/src/components/astro/blog/FeaturedPosts.astro @@ -5,6 +5,7 @@ import { getLocale } from "@i18n/utils"; import { getCollection } from "astro:content"; import Section from "../global/Section.astro"; import PostsGrid from "./PostsGrid.astro"; +import { getFilteredPostsCollection } from "@utils"; interface Props { postSize?: number; @@ -19,18 +20,7 @@ const locale = getLocale(Astro.url); await loadNamespaces(locale, ["blog"]); //Blogs -const allPosts = await getCollection("posts", ({ data }) => { - return data.language === locale && !data.hidden && data.featured; -}); - -const filteredPosts = - allPosts === undefined - ? undefined - : allPosts - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }) - .slice(0, postSize); +const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, featured: true, slice: postSize}); const sectionProps = { id: "featuredPosts", diff --git a/src/components/astro/blog/RecentPosts.astro b/src/components/astro/blog/RecentPosts.astro index 59f985d..13c6ec7 100644 --- a/src/components/astro/blog/RecentPosts.astro +++ b/src/components/astro/blog/RecentPosts.astro @@ -5,6 +5,7 @@ import { getCollection } from "astro:content"; import { BLOG } from "src/config/blog"; import Section from "../global/Section.astro"; import PostsGrid from "./PostsGrid.astro"; +import { getFilteredPostsCollection } from "@utils"; interface Props { postSize?: number; @@ -19,18 +20,7 @@ const locale = getLocale(Astro.url); await loadNamespaces(locale, ["blog"]); //Blogs -const allPosts = await getCollection("posts", ({ data }) => { - return data.language === locale && !data.hidden && (filterFeatured ? !data.featured : true); -}); - -const filteredPosts = - allPosts === undefined - ? undefined - : allPosts - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }) - .slice(0, postSize); +const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, featured: filterFeatured, slice: postSize}); const sectionProps = { id: "recentPosts", diff --git a/src/components/astro/blog/SmallBlogPostPreview.astro b/src/components/astro/blog/SmallBlogPostPreview.astro index ae17629..8881435 100644 --- a/src/components/astro/blog/SmallBlogPostPreview.astro +++ b/src/components/astro/blog/SmallBlogPostPreview.astro @@ -2,9 +2,7 @@ import FormattedDate from "@components/astro/blog/FormattedDate.astro"; import { loadNamespaces, t } from "@i18n/i18n"; import { getLocale } from "@i18n/utils"; -import { getBlogPostUrl } from "@utils/getBlogPostUrl"; -import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale"; -import { getOgImageUrl } from "@utils/getOgImageUrl"; +import { getBlogPostUrl, getCategoryTitleByLocale, getOgImageUrl } from "@utils"; import type { CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; diff --git a/src/components/astro/blog/Tag.astro b/src/components/astro/blog/Tag.astro index a496598..7d929c2 100644 --- a/src/components/astro/blog/Tag.astro +++ b/src/components/astro/blog/Tag.astro @@ -1,7 +1,7 @@ --- import { t } from "@i18n/i18n"; import { getLocale } from "@i18n/utils"; -import { getTagByLocale } from "@utils/getTagByLocale"; +import { getFilteredPostsCollection, getTagByLocale } from "@utils"; import { Icon } from "astro-icon/components"; import { getCollection, type CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; @@ -16,20 +16,7 @@ const locale = getLocale(Astro.url); const title = await getTagByLocale(locale, tag.id); const url = getRelativeLocaleUrl(locale, `/blog/tags/${tag.id}/`); - -const tagPosts = await getCollection("posts", ({ data }) => { - return !data.hidden && data.language === locale && data.tags.find((tag) => tag.id === tag.id); -}); - -// Only last 3 recent -const filteredPosts = - tagPosts === undefined - ? undefined - : tagPosts - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }) - .slice(0, 3); +const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, tagId: tag.id}); ---
  • diff --git a/src/components/astro/blog/TagList.astro b/src/components/astro/blog/TagList.astro index 3bd3496..e8b6209 100644 --- a/src/components/astro/blog/TagList.astro +++ b/src/components/astro/blog/TagList.astro @@ -1,6 +1,6 @@ --- import { getLocale } from "@i18n/utils"; -import { getTagByLocale } from "@utils/getTagByLocale"; +import { getTagByLocale } from "@utils"; import { type CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; diff --git a/src/components/astro/global/HeadHrefLangs.astro b/src/components/astro/global/HeadHrefLangs.astro index 0cfcec7..b206623 100644 --- a/src/components/astro/global/HeadHrefLangs.astro +++ b/src/components/astro/global/HeadHrefLangs.astro @@ -1,8 +1,7 @@ --- import { defaultLocale, locales } from "@config/i18n"; import { getPathFromUrl } from "@i18n/utils"; -import { getAbsoluteBlogPostUrl } from "@utils/getAbsoluteBlogPostUrl"; -import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale"; +import { getAbsoluteBlogPostUrl, getBlogPostByIdAndLocale } from "@utils"; import type { CollectionEntry } from "astro:content"; import { getAbsoluteLocaleUrl } from "astro:i18n"; diff --git a/src/components/astro/global/LanguageSelector.astro b/src/components/astro/global/LanguageSelector.astro index fb136fc..5810a82 100644 --- a/src/components/astro/global/LanguageSelector.astro +++ b/src/components/astro/global/LanguageSelector.astro @@ -5,8 +5,7 @@ import { locales } from "@config/i18n"; import { loadNamespaces } from "@i18n/i18n"; import { getLocale, getPathFromUrl } from "@i18n/utils"; -import { getBlogPostByIdAndLocale } from "@utils/getBlogPostByIdAndLocale"; -import { getBlogPostUrl } from "@utils/getBlogPostUrl"; +import { getBlogPostByIdAndLocale, getBlogPostUrl } from "@utils"; import { Icon } from "astro-icon/components"; import type { CollectionEntry } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; diff --git a/src/components/astro/projects/ProjectCard.astro b/src/components/astro/projects/ProjectCard.astro index 64f05aa..cbb20fa 100644 --- a/src/components/astro/projects/ProjectCard.astro +++ b/src/components/astro/projects/ProjectCard.astro @@ -1,5 +1,5 @@ --- -import { extractFileNameAndExtension } from "@utils/extractFilenameAndExtension"; +import { extractFileNameAndExtension } from "@utils"; import type { ImageMetadata } from "astro"; import { Image } from "astro:assets"; import type { CollectionEntry } from "astro:content"; diff --git a/src/content/categories/guides.yaml b/src/content/categories/guides.yaml index 07b531f..7a77431 100644 --- a/src/content/categories/guides.yaml +++ b/src/content/categories/guides.yaml @@ -2,7 +2,7 @@ id: guides languages: cs: title: Návody - description: Návody různých témat.. + description: Různé návody pro různá témata. en: title: Guides description: Various guides about various topics. diff --git a/src/content/categories/lifestyle.yaml b/src/content/categories/lifestyle.yaml new file mode 100644 index 0000000..98133cc --- /dev/null +++ b/src/content/categories/lifestyle.yaml @@ -0,0 +1,8 @@ +id: lifestyle +languages: + cs: + title: Život + description: Témata o životě. + en: + title: Lifestyle + description: Lifestyle topics diff --git a/src/content/categories/software.yaml b/src/content/categories/software.yaml new file mode 100644 index 0000000..472b867 --- /dev/null +++ b/src/content/categories/software.yaml @@ -0,0 +1,8 @@ +id: software +languages: + cs: + title: Software + description: Vše kolem software. + en: + title: Software + description: Topics about software. diff --git a/src/content/posts/cs/2023-01-01-typography-example.md b/src/content/posts/cs/2023-01-01-typography-example.md index 5ddb0e8..a73ea71 100644 --- a/src/content/posts/cs/2023-01-01-typography-example.md +++ b/src/content/posts/cs/2023-01-01-typography-example.md @@ -2,13 +2,17 @@ title: "Příklad typografie" postId: "post-1" language: "cs" -featured: false +featured: true pubDateTime: 2022-07-01 modDatetime: 2022-07-01 -description: "Tento příspěvěk slouží pro testování typografie." -author: "Dalibor Hon" +description: "This is the first post of my new Astro blog." +author: "Astro Learner" +image: + url: "https://docs.astro.build/assets/full-logo-light.png" + alt: "The full Astro logo." tags: - astro + - community hidden: false --- diff --git a/src/content/posts/cs/2023-12-29-localized-slug-title.md b/src/content/posts/cs/2023-12-29-localized-slug-title.md new file mode 100644 index 0000000..83ecbcd --- /dev/null +++ b/src/content/posts/cs/2023-12-29-localized-slug-title.md @@ -0,0 +1,14 @@ +--- +title: Lokalizovaná část URL +postId: 0636fd5a-2786-4501-b1bb-634844ff32f1 +description: Lokalizovaná část URL +author: Dalibor Hon +tags: + - successes +language: cs +hidden: false +featured: true +pubDateTime: 2023-12-29T23:20:35.541 +--- + +Lokalizovaná část URL diff --git a/src/content/posts/cs/2024-01-02-test-post-from-identity.md b/src/content/posts/cs/2024-01-02-test-post-from-identity.md new file mode 100644 index 0000000..d1f059f --- /dev/null +++ b/src/content/posts/cs/2024-01-02-test-post-from-identity.md @@ -0,0 +1,15 @@ +--- +title: Test post from identity +postId: 943b9bc5-49e8-4849-95f3-f982f4d51c24 +description: Test post from identity +author: Dalibor Hon +tags: + - astro +language: cs +hidden: true +featured: false +pubDateTime: 2024-01-02T13:34:43+01:00 +modDatetime: 2024-01-02T13:34:44+01:00 +--- + +Test post from identity diff --git a/src/content/posts/cs/2024-01-07-test-post-from-cms.md b/src/content/posts/cs/2024-01-07-test-post-from-cms.md new file mode 100644 index 0000000..9df9091 --- /dev/null +++ b/src/content/posts/cs/2024-01-07-test-post-from-cms.md @@ -0,0 +1,17 @@ +--- +title: Testovací post z CMS +postId: ec0b8590-3327-44e1-b8a6-e44388b55ec6 +description: Testovací post z CMS +author: Dalibor Hon +tags: + - successes +category: software +language: cs +hidden: false +featured: false +ogImage: /assets/uploads/img/astro.jpg +pubDateTime: 2024-01-07T21:37:39+01:00 +modDatetime: 2024-01-10T21:37:39+01:00 +--- + +Testovací post z CMS diff --git a/src/content/posts/cs/2024-01-13-test-post-with-external-image.md b/src/content/posts/cs/2024-01-13-test-post-with-external-image.md new file mode 100644 index 0000000..902b62e --- /dev/null +++ b/src/content/posts/cs/2024-01-13-test-post-with-external-image.md @@ -0,0 +1,17 @@ +--- +title: Test externího obrázku +postId: 66db8404-5409-4ff0-8d07-1003b3619fbe +description: Test externího obrázku +author: Dalibor Hon +tags: + - community +category: software +language: cs +hidden: false +featured: false +ogImage: https://astro.build/og/astro.jpg +pubDateTime: 2024-01-13T22:09:12+01:00 +modDatetime: "" +--- + +Test externího obrázku diff --git a/src/content/posts/cs/post-2.md b/src/content/posts/cs/post-2.md new file mode 100644 index 0000000..8147eb3 --- /dev/null +++ b/src/content/posts/cs/post-2.md @@ -0,0 +1,153 @@ +--- +title: Můj druhý příspěvek +postId: 3458b58b-7be5-4f6a-9a81-79da3b4c089c +description: After learning some Astro, I couldn't stop! +author: Astro Learner +language: cs +image: + url: https://docs.astro.build/assets/arc.webp + alt: Thumbnail of Astro arcs. +tags: + - astro + - community + - successes +hidden: false +featured: true +pubDateTime: 2024-01-04T14:10:16+01:00 +modDatetime: "" +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. +> This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +2. List item 2 + 1. Nested list item A + 2. Nested list item B +3. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +2. Another item + - Unordered sub-list. +3. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +4. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com "Google's Homepage") + +[Reference-style link][arbitrary case-insensitive reference text] + +[You can use numbers for reference-style link definitions][1] + +Or leave it empty and use the [link text itself]. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +Images included in _\_posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp "Logo Title Text 1") + +## Table + +| Tables | Are | Cool | +| ------------- | :-----------: | ---: | +| col 3 is | right-aligned | 1600 | +| col 2 is | centered | 12 | +| zebra stripes | are neat | 1 | + +| Markdown | Less | Pretty | +| -------- | --------- | ---------- | +| _Still_ | `renders` | **nicely** | +| 1 | 2 | 3 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/posts/cs/post-3.md b/src/content/posts/cs/post-3.md new file mode 100644 index 0000000..faaf54b --- /dev/null +++ b/src/content/posts/cs/post-3.md @@ -0,0 +1,157 @@ +--- +title: "Můj třetí příspěvek" +postId: "post-3" +language: "cs" +author: Astro Learner +description: "I had some challenges, but asking in the community really helped!" +image: + url: "https://docs.astro.build/assets/rays.webp" + alt: "Thumbnail of Astro rays." +pubDateTime: 2022-07-15 +tags: + - astro + - community + - successes +hidden: false +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Headings + +# H1 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. +> This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +2. List item 2 + 1. Nested list item A + 2. Nested list item B +3. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +2. Another item + - Unordered sub-list. +3. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +4. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com "Google's Homepage") + +[Reference-style link][arbitrary case-insensitive reference text] + +[You can use numbers for reference-style link definitions][1] + +Or leave it empty and use the [link text itself]. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +Images included in _\_posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp "Logo Title Text 1") + +## Table + +| Tables | Are | Cool | +| ------------- | :-----------: | ---: | +| col 3 is | right-aligned | 1600 | +| col 2 is | centered | 12 | +| zebra stripes | are neat | 1 | + +| Markdown | Less | Pretty | +| -------- | --------- | ---------- | +| _Still_ | `renders` | **nicely** | +| 1 | 2 | 3 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/posts/cs/post-4.md b/src/content/posts/cs/post-4.md new file mode 100644 index 0000000..14f9b5e --- /dev/null +++ b/src/content/posts/cs/post-4.md @@ -0,0 +1,138 @@ +--- +title: Příspěvek v kategorii +postId: post-4 +language: cs +author: Astro Learner +description: This post will show up on its own! +image: + url: https://docs.astro.build/default-og-image.png + alt: The word astro against an illustration of planets and stars. +pubDateTime: 2023-12-29T00:56:09.755+01:00 +tags: + - astro + - community + - successes +hidden: false +category: guides +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Headings + +# H1 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +1. List item 2 + 1. Nested list item A + 1. Nested list item B +1. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +1. Another item + 1. Unordered sub-list. +1. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +1. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com) + +## Images + +Images included in \__posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp) + +## Table + +| 1 | 2 | +| --- | --- | +| 3 | 4 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/posts/en/2023-01-01-typography-example.md b/src/content/posts/en/2023-01-01-typography-example.md index 3511aa8..0f9c4df 100644 --- a/src/content/posts/en/2023-01-01-typography-example.md +++ b/src/content/posts/en/2023-01-01-typography-example.md @@ -2,13 +2,17 @@ title: "Typography example (en)" postId: "post-1" language: "en" -featured: false +featured: true pubDateTime: 2022-07-01 modDatetime: 2022-07-01 -description: "This post serves as a typography test." -author: "Dalibor Hon" +description: "This is the first post of my new Astro blog." +author: "Astro Learner" +image: + url: "https://docs.astro.build/assets/full-logo-light.png" + alt: "The full Astro logo." tags: - astro + - community hidden: false --- diff --git a/src/content/posts/en/2023-12-29-localized-slug-title.md b/src/content/posts/en/2023-12-29-localized-slug-title.md new file mode 100644 index 0000000..9541148 --- /dev/null +++ b/src/content/posts/en/2023-12-29-localized-slug-title.md @@ -0,0 +1,14 @@ +--- +title: Localized slug title +postId: 0636fd5a-2786-4501-b1bb-634844ff32f1 +description: Localized slug title +author: Dalibor Hon +tags: + - successes +language: en +hidden: false +featured: true +pubDateTime: 2023-12-29T23:20:35.541 +--- + +Localized slug title diff --git a/src/content/posts/en/2024-01-02-test-post-from-identity.md b/src/content/posts/en/2024-01-02-test-post-from-identity.md new file mode 100644 index 0000000..892b418 --- /dev/null +++ b/src/content/posts/en/2024-01-02-test-post-from-identity.md @@ -0,0 +1,15 @@ +--- +title: Test post from identity +postId: 943b9bc5-49e8-4849-95f3-f982f4d51c24 +description: Test post from identity +author: Dalibor Hon +tags: + - astro +language: en +hidden: true +featured: false +pubDateTime: 2024-01-02T13:34:43+01:00 +modDatetime: 2024-01-02T13:34:44+01:00 +--- + +Test post from identity diff --git a/src/content/posts/en/2024-01-07-test-post-from-cms.md b/src/content/posts/en/2024-01-07-test-post-from-cms.md new file mode 100644 index 0000000..a464ae5 --- /dev/null +++ b/src/content/posts/en/2024-01-07-test-post-from-cms.md @@ -0,0 +1,17 @@ +--- +title: Test post from CMS +postId: ec0b8590-3327-44e1-b8a6-e44388b55ec6 +description: Test post from CMS +author: Dalibor Hon +tags: + - successes +category: software +language: en +hidden: false +featured: false +ogImage: /assets/uploads/img/astro.jpg +pubDateTime: 2024-01-07T21:37:39+01:00 +modDatetime: 2024-01-10T21:37:39+01:00 +--- + +Test post from CMS diff --git a/src/content/posts/en/2024-01-13-test-post-with-external-image.md b/src/content/posts/en/2024-01-13-test-post-with-external-image.md new file mode 100644 index 0000000..f4ba779 --- /dev/null +++ b/src/content/posts/en/2024-01-13-test-post-with-external-image.md @@ -0,0 +1,17 @@ +--- +title: Test post with external image +postId: 66db8404-5409-4ff0-8d07-1003b3619fbe +description: Test post with external image +author: Dalibor Hon +tags: + - community +category: software +language: en +hidden: false +featured: false +ogImage: https://astro.build/og/astro.jpg +pubDateTime: 2024-01-13T22:09:12+01:00 +modDatetime: "" +--- + +Testing external image diff --git a/src/content/posts/en/post-2.md b/src/content/posts/en/post-2.md new file mode 100644 index 0000000..aad7fff --- /dev/null +++ b/src/content/posts/en/post-2.md @@ -0,0 +1,153 @@ +--- +title: My Second Blog Post +postId: 3458b58b-7be5-4f6a-9a81-79da3b4c089c +description: After learning some Astro, I couldn't stop! +author: Astro Learner +language: en +image: + url: https://docs.astro.build/assets/arc.webp + alt: Thumbnail of Astro arcs. +tags: + - astro + - community + - successes +hidden: false +featured: true +pubDateTime: 2024-01-04T14:10:16+01:00 +modDatetime: "" +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. +> This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +2. List item 2 + 1. Nested list item A + 2. Nested list item B +3. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +2. Another item + - Unordered sub-list. +3. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +4. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com "Google's Homepage") + +[Reference-style link][arbitrary case-insensitive reference text] + +[You can use numbers for reference-style link definitions][1] + +Or leave it empty and use the [link text itself]. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +Images included in _\_posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp "Logo Title Text 1") + +## Table + +| Tables | Are | Cool | +| ------------- | :-----------: | ---: | +| col 3 is | right-aligned | 1600 | +| col 2 is | centered | 12 | +| zebra stripes | are neat | 1 | + +| Markdown | Less | Pretty | +| -------- | --------- | ---------- | +| _Still_ | `renders` | **nicely** | +| 1 | 2 | 3 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/posts/en/post-3.md b/src/content/posts/en/post-3.md new file mode 100644 index 0000000..4b86a4c --- /dev/null +++ b/src/content/posts/en/post-3.md @@ -0,0 +1,157 @@ +--- +title: My Third Blog Post +postId: "post-3" +language: "en" +author: Astro Learner +description: "I had some challenges, but asking in the community really helped!" +image: + url: "https://docs.astro.build/assets/rays.webp" + alt: "Thumbnail of Astro rays." +pubDateTime: 2022-07-15 +tags: + - astro + - community + - successes +hidden: false +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Headings + +# H1 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. +> This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +2. List item 2 + 1. Nested list item A + 2. Nested list item B +3. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +2. Another item + - Unordered sub-list. +3. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +4. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com "Google's Homepage") + +[Reference-style link][arbitrary case-insensitive reference text] + +[You can use numbers for reference-style link definitions][1] + +Or leave it empty and use the [link text itself]. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +Images included in _\_posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp "Logo Title Text 1") + +## Table + +| Tables | Are | Cool | +| ------------- | :-----------: | ---: | +| col 3 is | right-aligned | 1600 | +| col 2 is | centered | 12 | +| zebra stripes | are neat | 1 | + +| Markdown | Less | Pretty | +| -------- | --------- | ---------- | +| _Still_ | `renders` | **nicely** | +| 1 | 2 | 3 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/posts/en/post-4.md b/src/content/posts/en/post-4.md new file mode 100644 index 0000000..6670574 --- /dev/null +++ b/src/content/posts/en/post-4.md @@ -0,0 +1,158 @@ +--- +title: Post in Category +postId: "post-4" +language: "en" +author: Astro Learner +description: "This post will show up on its own!" +image: + url: "https://docs.astro.build/default-og-image.png" + alt: "The word astro against an illustration of planets and stars." +pubDateTime: 2022-08-08 +tags: + - astro + - community + - successes +hidden: false +category: guides +--- + +This is a paragraph. Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Headings + +# H1 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## H2 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +### H3 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +#### H4 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +##### H5 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +###### H6 For example + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +## Emphasis + +Emphasis, aka italics, with _asterisks_ or _underscores_. + +Strong emphasis, aka bold, with **asterisks** or **underscores**. + +Strikethrough uses two tildes. ~~Scratch this.~~ + +## Blockquotes + +> Blockquotes are very handy in email to emulate reply text. +> This line is part of the same quote. + +Quote break. + +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote. + +## Horizontal separator + +This is a horizontal separator: + +--- + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +--- + +## List types + +### Ordered list + +1. List item 1 +2. List item 2 + 1. Nested list item A + 2. Nested list item B +3. List item 3 + +### Unordered list + +- List item +- List item + - Nested list item + - Nested list item + - Double nested list item + - Double nested list item +- List item + +### Mixed list + +1. First ordered list item +2. Another item + - Unordered sub-list. +3. Actual numbers don't matter, just that it's a number + 1. Ordered sub-list +4. And another item. + +## Links + +[Inline-style link](https://www.google.com) + +[Inline-style link with title](https://www.google.com "Google's Homepage") + +[Reference-style link][arbitrary case-insensitive reference text] + +[You can use numbers for reference-style link definitions][1] + +Or leave it empty and use the [link text itself]. + +Some text to show that the reference links can follow later. + +[arbitrary case-insensitive reference text]: https://www.mozilla.org +[1]: http://slashdot.org +[link text itself]: http://www.reddit.com + +## Images + +Images included in _\_posts_ folder are lazy loaded. + +Inline-style: +![alt text](https://docs.astro.build/assets/arc.webp "Logo Title Text 1") + +## Table + +| Tables | Are | Cool | +| ------------- | :-----------: | ---: | +| col 3 is | right-aligned | 1600 | +| col 2 is | centered | 12 | +| zebra stripes | are neat | 1 | + +| Markdown | Less | Pretty | +| -------- | --------- | ---------- | +| _Still_ | `renders` | **nicely** | +| 1 | 2 | 3 | + +## Syntax highlight + +```javascript +var s = "JavaScript syntax highlighting"; +var s = "JavaScript syntax highlighting"; +alert(s); +``` + +Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur vero esse non molestias eos excepturi, inventore atque cupiditate. Sed voluptatem quas omnis culpa, et odit. + +```python +s = "Python syntax highlighting" +print s +``` diff --git a/src/content/project-tags/astrojs.json b/src/content/project-tags/astrojs.json index d9cc257..eb9285b 100644 --- a/src/content/project-tags/astrojs.json +++ b/src/content/project-tags/astrojs.json @@ -2,4 +2,4 @@ "id": "astrojs", "title": "Astro.js", "bgColor": "rgb(232,121,249)" -} +} \ No newline at end of file diff --git a/src/content/project-tags/javascript.json b/src/content/project-tags/javascript.json index 496a7d5..90f3b80 100644 --- a/src/content/project-tags/javascript.json +++ b/src/content/project-tags/javascript.json @@ -2,4 +2,4 @@ "id": "javascript", "title": "JavaScript", "bgColor": "rgb(250,204,21)" -} +} \ No newline at end of file diff --git a/src/content/project-tags/kmp.json b/src/content/project-tags/kmp.json index a58a460..42aa736 100644 --- a/src/content/project-tags/kmp.json +++ b/src/content/project-tags/kmp.json @@ -2,4 +2,4 @@ "id": "kmp", "title": "Kotlin Multiplatform", "bgColor": "linear-gradient(to right,#ef4857 0,#de4970 20%,#b44db0 50%,#7f52ff 100%)" -} +} \ No newline at end of file diff --git a/src/content/project-tags/react.json b/src/content/project-tags/react.json index 4bb1292..6a5e63d 100644 --- a/src/content/project-tags/react.json +++ b/src/content/project-tags/react.json @@ -2,4 +2,4 @@ "id": "react", "title": "React", "bgColor": "rgb(20,158,202)" -} +} \ No newline at end of file diff --git a/src/content/project-tags/typescript.json b/src/content/project-tags/typescript.json index 2cdc74a..cd762d1 100644 --- a/src/content/project-tags/typescript.json +++ b/src/content/project-tags/typescript.json @@ -2,4 +2,4 @@ "id": "typescript", "title": "TypeScript", "bgColor": "rgb(251,113,133)" -} +} \ No newline at end of file diff --git a/src/content/project-tags/web.json b/src/content/project-tags/web.json index 88093c3..a4d6ff7 100644 --- a/src/content/project-tags/web.json +++ b/src/content/project-tags/web.json @@ -2,4 +2,4 @@ "id": "web", "title": "Web", "bgColor": "rgb(163,230,53)" -} +} \ No newline at end of file diff --git a/src/content/projects/cs/github-oauth-provider-for-static-cms.md b/src/content/projects/cs/github-oauth-provider-for-static-cms.md index d43f4f1..caf5fc3 100644 --- a/src/content/projects/cs/github-oauth-provider-for-static-cms.md +++ b/src/content/projects/cs/github-oauth-provider-for-static-cms.md @@ -2,12 +2,11 @@ title: Zprostředkovatel GitHub OAuth pro Static CMS href: https://github.com/dallyh/static-cms-gh-oauth-provider projectTags: - - astrojs - - typescript - - web + - astrojs + - typescript + - web language: cs image: /assets/uploads/img/projects/gh-oauth.svg projectStartDate: 2024-01-01 --- - -Rozhraní API, které poskytuje autentizaci pro systém Static CMS prostřednictvím služby GitHub OAuth. +Rozhraní API, které poskytuje autentizaci pro systém Static CMS prostřednictvím služby GitHub OAuth. \ No newline at end of file diff --git a/src/content/projects/cs/lemmy-kotlin-client.md b/src/content/projects/cs/lemmy-kotlin-client.md index 278fed7..f7940b7 100644 --- a/src/content/projects/cs/lemmy-kotlin-client.md +++ b/src/content/projects/cs/lemmy-kotlin-client.md @@ -2,10 +2,9 @@ title: Lemmy Kotlin Client href: https://github.com/dallyh/lemmy-kt-client projectTags: - - kmp + - kmp language: cs image: /assets/uploads/img/projects/lemmy-logo.svg projectStartDate: 2023-08-20 --- - -Multiplatformní klient postavený na platofrmě Kotlin Multiplatform pro platformu [Lemmy](https://join-lemmy.org/). +Multiplatformní klient postavený na platofrmě Kotlin Multiplatform pro platformu [Lemmy](https://join-lemmy.org/). \ No newline at end of file diff --git a/src/content/projects/cs/this-web.md b/src/content/projects/cs/this-web.md index abf9beb..d28f59c 100644 --- a/src/content/projects/cs/this-web.md +++ b/src/content/projects/cs/this-web.md @@ -2,14 +2,13 @@ title: Tento web href: https://github.com/dallyh/daliborhon.dev projectTags: - - astrojs - - typescript - - javascript - - react - - web + - astrojs + - typescript + - javascript + - react + - web language: cs image: /assets/uploads/img/projects/this-web.svg projectStartDate: 2099-12-31 --- - -Zdrojový kód této webové stránky +Zdrojový kód této webové stránky \ No newline at end of file diff --git a/src/content/projects/en/github-oauth-provider-for-static-cms.md b/src/content/projects/en/github-oauth-provider-for-static-cms.md index 1e331d6..e119e1b 100644 --- a/src/content/projects/en/github-oauth-provider-for-static-cms.md +++ b/src/content/projects/en/github-oauth-provider-for-static-cms.md @@ -2,12 +2,11 @@ title: GitHub OAuth provider for Static CMS href: https://github.com/dallyh/static-cms-gh-oauth-provider projectTags: - - astrojs - - typescript - - web + - astrojs + - typescript + - web language: en image: /assets/uploads/img/projects/gh-oauth.svg projectStartDate: 2024-01-01 --- - -An API that provides authentification for Static CMS through GitHub's OAuth. +An API that provides authentification for Static CMS through GitHub's OAuth. \ No newline at end of file diff --git a/src/content/projects/en/lemmy-kotlin-client.md b/src/content/projects/en/lemmy-kotlin-client.md index fda160f..824177e 100644 --- a/src/content/projects/en/lemmy-kotlin-client.md +++ b/src/content/projects/en/lemmy-kotlin-client.md @@ -2,10 +2,9 @@ title: Lemmy Kotlin Client href: https://github.com/dallyh/lemmy-kt-client projectTags: - - kmp + - kmp language: en image: /assets/uploads/img/projects/lemmy-logo.svg projectStartDate: 2023-08-20 --- - -A Kotlin Multiplatform client for [Lemmy](https://join-lemmy.org/). +A Kotlin Multiplatform client for [Lemmy](https://join-lemmy.org/). \ No newline at end of file diff --git a/src/content/projects/en/this-web.md b/src/content/projects/en/this-web.md index 23a0013..ea130d0 100644 --- a/src/content/projects/en/this-web.md +++ b/src/content/projects/en/this-web.md @@ -2,14 +2,13 @@ title: This web href: https://github.com/dallyh/daliborhon.dev projectTags: - - astrojs - - typescript - - javascript - - react - - web + - astrojs + - typescript + - javascript + - react + - web language: en image: /assets/uploads/img/projects/this-web.svg projectStartDate: 2099-12-31 --- - Source code for this website diff --git a/src/content/tags/community.yaml b/src/content/tags/community.yaml new file mode 100644 index 0000000..4432dc6 --- /dev/null +++ b/src/content/tags/community.yaml @@ -0,0 +1,4 @@ +id: community +languages: + cs: komunita + en: community diff --git a/src/content/tags/successes.yaml b/src/content/tags/successes.yaml new file mode 100644 index 0000000..0977302 --- /dev/null +++ b/src/content/tags/successes.yaml @@ -0,0 +1,4 @@ +id: successes +languages: + cs: úspěchy + en: successes diff --git a/src/i18n/utils.ts b/src/i18n/utils.ts index 6daf8e1..b2d2a5a 100644 --- a/src/i18n/utils.ts +++ b/src/i18n/utils.ts @@ -1,5 +1,5 @@ import { defaultLocale, locales, type AllowedLocales } from "@config/i18n"; -import { removeTrailingSlash } from "@utils/removeTrailingSlash"; +import { removeTrailingSlash } from "@utils"; export function getLocale(url: URL): AllowedLocales { const pathSegments = url.pathname.split("/"); diff --git a/src/layouts/BlogPostLayout.astro b/src/layouts/BlogPostLayout.astro index 60c836b..7f885ab 100644 --- a/src/layouts/BlogPostLayout.astro +++ b/src/layouts/BlogPostLayout.astro @@ -7,14 +7,14 @@ import TagList from "@components/astro/blog/TagList.astro"; import BreadCrumbs from "@components/astro/blog/BreadCrumbs.astro"; import BreadCrumbsItem from "@components/astro/blog/BreadCrumbsItem.astro"; import { getRelativeLocaleUrl } from "astro:i18n"; -import { getOgImageUrl } from "@utils/getOgImageUrl"; +import { getOgImageUrl } from "@utils"; import Footer from "@components/astro/global/Footer.astro"; import HeadHrefLangs from "@components/astro/global/HeadHrefLangs.astro"; import Navigation from "@components/astro/global/Navigation.astro"; import "../styles/markdown.css"; -import { getPostImgTransitionName } from "@utils/getPostImgTransitionName"; +import { getPostImgTransitionName } from "@utils"; import { loadNamespaces, t } from "@i18n/i18n"; -import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale"; +import { getCategoryTitleByLocale } from "@utils"; interface Props { post: CollectionEntry<"posts">; diff --git a/src/layouts/PostsLayout.astro b/src/layouts/PostsLayout.astro index 757843c..9fab3c8 100644 --- a/src/layouts/PostsLayout.astro +++ b/src/layouts/PostsLayout.astro @@ -28,8 +28,6 @@ const layoutProps = { title: `${t("blog.all_posts_title")}`, description: t("blog.blog_site_description"), }; - -console.log(page); --- diff --git a/src/pages/[...lang]/blog/categories/[...category].astro b/src/pages/[...lang]/blog/categories/[...category].astro index d032629..77d0647 100644 --- a/src/pages/[...lang]/blog/categories/[...category].astro +++ b/src/pages/[...lang]/blog/categories/[...category].astro @@ -7,44 +7,23 @@ import { locales } from "@config/i18n"; import { loadNamespaces, t } from "@i18n/i18n"; import { getLocale, getRoutingLocale } from "@i18n/utils"; import PageLayout from "@layouts/PageLayout.astro"; -import { getCategoryTitleByLocale } from "@utils/getCategoryByLocale"; +import { getCategoryTitleByLocale, getFilteredPostsCollection } from "@utils"; import { getCollection } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; -// This is kinda complicated export async function getStaticPaths() { - const allPosts = await getCollection("posts", ({ data }) => { - return !data.hidden; - }); - const categories = await getCollection("categories"); if (categories === undefined) { - const paths = locales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), category: undefined }, props: { posts: allPosts } }; - }); - - return paths; - } - - if (allPosts === undefined) { - const paths = categories.flatMap((cat) => { - return locales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), category: cat.id }, props: { posts: allPosts } }; - }); + const paths = locales.flatMap((locale) => { + return { params: { lang: getRoutingLocale(locale), category: undefined } }; }); - return paths; } - const blogLocales = allPosts.map((post) => { - return post.data.language; - }); - const uniqueLocales = [...new Set(blogLocales.flat())]; - const paths = categories.flatMap((cat) => { - return uniqueLocales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), category: cat.id }, props: { posts: allPosts } }; + return locales.map((locale) => { + return { params: { lang: getRoutingLocale(locale), category: cat.id } }; }); }); @@ -52,19 +31,9 @@ export async function getStaticPaths() { } const { category } = Astro.params; -const { posts } = Astro.props; const locale = getLocale(Astro.url); -const filteredPosts = - posts === undefined - ? undefined - : posts - .filter((post) => { - return post.data.category?.id == category && post.data.language === locale; - }) - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }); +const filteredPosts = await getFilteredPostsCollection({ locale: locale, sort: true, categoryId: category }); // i18next await loadNamespaces(locale, ["blog", "common"]); diff --git a/src/pages/[...lang]/blog/posts/[...page].astro b/src/pages/[...lang]/blog/posts/[...page].astro index c5befa8..b13433a 100644 --- a/src/pages/[...lang]/blog/posts/[...page].astro +++ b/src/pages/[...lang]/blog/posts/[...page].astro @@ -2,23 +2,22 @@ import { locales } from "@config/i18n"; import { getRoutingLocale } from "@i18n/utils"; import PostsLayout from "@layouts/PostsLayout.astro"; +import { getFilteredPostsCollection } from "@utils"; import type { GetStaticPathsOptions } from "astro"; -import { getCollection } from "astro:content"; import { BLOG } from "src/config/blog"; export async function getStaticPaths({ paginate }: GetStaticPathsOptions) { - const posts = await getCollection("posts", ({ data }) => { - return !data.hidden; - }); - - return locales.flatMap((locale) => { - const filteredPosts = posts === undefined ? [] : posts.filter((post) => post.data.language === locale).sort((a, b) => new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf()); - - return paginate(filteredPosts, { - params: { lang: getRoutingLocale(locale) }, - pageSize: BLOG.pageSize, - }); - }); + const paths = await Promise.all( + locales.flatMap(async (locale) => { + const filteredPosts = await getFilteredPostsCollection({locale: locale, sort: true}) ?? []; + + return paginate(filteredPosts, { + params: { lang: getRoutingLocale(locale) }, + pageSize: BLOG.pageSize, + }); + }), + ); + return paths[0]; } const { page } = Astro.props; diff --git a/src/pages/[...lang]/blog/posts/[...slug]/index.astro b/src/pages/[...lang]/blog/posts/[...slug]/index.astro index a1652bb..e0896eb 100644 --- a/src/pages/[...lang]/blog/posts/[...slug]/index.astro +++ b/src/pages/[...lang]/blog/posts/[...slug]/index.astro @@ -1,21 +1,25 @@ --- import { getRoutingLocale } from "@i18n/utils"; import BlogPostLayout from "@layouts/BlogPostLayout.astro"; -import { getBlogPostSlug } from "@utils/getBlogPostSlug"; +import { getAllVisiblePostsCollection, getBlogPostSlug } from "@utils"; import { getCollection } from "astro:content"; export async function getStaticPaths() { - const allPosts = await getCollection("posts", ({ data }) => { - return !data.hidden; - }); - const paths = - allPosts === undefined - ? [] - : allPosts.map((post) => { - return { params: { lang: getRoutingLocale(post.data.language), slug: getBlogPostSlug(post.data.language, post) }, props: { post: post } }; - }); + const allPosts = await getAllVisiblePostsCollection(); - return paths; + if (allPosts === undefined) { + return []; + } + + return allPosts.map((post) => ({ + params: { + lang: getRoutingLocale(post.data.language), + slug: getBlogPostSlug(post.data.language, post), + }, + props: { + post: post, + }, + })); } const { post } = Astro.props; diff --git a/src/pages/[...lang]/blog/posts/[...slug]/index.png.ts b/src/pages/[...lang]/blog/posts/[...slug]/index.png.ts index 57631f5..1804ac5 100644 --- a/src/pages/[...lang]/blog/posts/[...slug]/index.png.ts +++ b/src/pages/[...lang]/blog/posts/[...slug]/index.png.ts @@ -1,7 +1,6 @@ import { defaultLocale } from "@config/i18n"; import { getRoutingLocale } from "@i18n/utils"; -import { generateOgImageForPost } from "@utils/generateOgImage"; -import { getBlogPostSlug } from "@utils/getBlogPostSlug"; +import { generateOgImageForPost, getBlogPostSlug } from "@utils"; import type { APIContext } from "astro"; import { getCollection, type CollectionEntry } from "astro:content"; diff --git a/src/pages/[...lang]/blog/posts/featured/index.astro b/src/pages/[...lang]/blog/posts/featured/index.astro index 9b6310d..57ff738 100644 --- a/src/pages/[...lang]/blog/posts/featured/index.astro +++ b/src/pages/[...lang]/blog/posts/featured/index.astro @@ -27,7 +27,7 @@ const layoutProps = { - + diff --git a/src/pages/[...lang]/blog/tags/[...tag].astro b/src/pages/[...lang]/blog/tags/[...tag].astro index 52fe30d..daa913d 100644 --- a/src/pages/[...lang]/blog/tags/[...tag].astro +++ b/src/pages/[...lang]/blog/tags/[...tag].astro @@ -7,63 +7,31 @@ import { locales } from "@config/i18n"; import { loadNamespaces, t } from "@i18n/i18n"; import { getLocale, getRoutingLocale } from "@i18n/utils"; import PageLayout from "@layouts/PageLayout.astro"; -import { getTagByLocale } from "@utils/getTagByLocale"; +import { getFilteredPostsCollection, getTagByLocale } from "@utils"; import { getCollection } from "astro:content"; import { getRelativeLocaleUrl } from "astro:i18n"; // This is kinda complicated export async function getStaticPaths() { - const allPosts = await getCollection("posts", ({ data }) => { - return !data.hidden; - }); - const tags = await getCollection("tags"); if (tags === undefined) { - const paths = locales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), tag: undefined }, props: { posts: allPosts } }; - }); - - return paths; - } - - if (allPosts === undefined) { - const paths = tags.flatMap((tag) => { - return locales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), tag: tag.id }, props: { posts: allPosts } }; - }); - }); - + const paths = locales.map((locale) => ({ + params: { lang: getRoutingLocale(locale), tag: undefined} + })); return paths; } - const blogLocales = allPosts.map((post) => { - return post.data.language; - }); - const uniqueLocales = [...new Set(blogLocales.flat())]; - - const paths = tags.flatMap((tag) => { - return uniqueLocales.map((locale) => { - return { params: { lang: getRoutingLocale(locale), tag: tag.id }, props: { posts: allPosts } }; - }); - }); - - return paths; + return tags.flatMap((tag) => + locales.map((locale) => ({ + params: { lang: getRoutingLocale(locale), tag: tag.id } + })) + ); } const { tag } = Astro.params; -const { posts } = Astro.props; const locale = getLocale(Astro.url); -const filteredPosts = - posts === undefined - ? undefined - : posts - .filter((post) => { - return post.data.tags.some((t) => t.id === tag) && post.data.language === locale; - }) - .sort((a, b) => { - return new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf(); - }); +const filteredPosts = await getFilteredPostsCollection({sort: true, locale: locale, tagId: tag }); // i18next await loadNamespaces(locale, ["blog", "common"]); diff --git a/src/pages/[...lang]/blog/tags/index.astro b/src/pages/[...lang]/blog/tags/index.astro index 860b291..a2c8739 100644 --- a/src/pages/[...lang]/blog/tags/index.astro +++ b/src/pages/[...lang]/blog/tags/index.astro @@ -21,7 +21,7 @@ const layoutProps = { title: `${t("blog.categories")} - Blog`, description: t("blog.blog_site_description"), }; -// Categories + const tags = await getCollection("tags"); const sorted = tags === undefined ? undefined : tags.sort((a, b) => a.data.languages[locale].localeCompare(b.data.languages[locale])); --- diff --git a/src/pages/[...lang]/og.png.ts b/src/pages/[...lang]/og.png.ts index a599482..db09efb 100644 --- a/src/pages/[...lang]/og.png.ts +++ b/src/pages/[...lang]/og.png.ts @@ -1,6 +1,6 @@ import { defaultLocale } from "@config/i18n"; import { getStaticPaths } from "@i18n/utils"; -import { generateOgImageForSite } from "@utils/generateOgImage"; +import { generateOgImageForSite } from "@utils"; import type { APIContext } from "astro"; export { getStaticPaths }; diff --git a/src/utils/getFilteredPostsCollection.ts b/src/utils/getFilteredPostsCollection.ts new file mode 100644 index 0000000..8c71ac3 --- /dev/null +++ b/src/utils/getFilteredPostsCollection.ts @@ -0,0 +1,68 @@ +import { getCollection, type CollectionEntry } from "astro:content"; + +interface FilteredPostsOptions { + featured?: boolean; + sort?: boolean; + locale?: string; + slice?: number; + categoryId?: string; + tagId?: string; +} + +export async function getFilteredPostsCollection(options: FilteredPostsOptions) { + const { featured, sort, locale, slice, categoryId, tagId } = options; + + let posts = await getCollection("posts", ({ data }) => { + return buildCondition(data, {featured, locale, categoryId, tagId}); + }); + + if (posts === undefined) return undefined; + + if (sort) { + posts = posts.sort((a, b) => new Date(b.data.pubDateTime).valueOf() - new Date(a.data.pubDateTime).valueOf()); + } + + if (slice) { + posts = posts.slice(0, slice); + } + + return posts; +} + +export async function getAllVisiblePostsCollection() { + return getCollection("posts", ({ data }) => { + return buildCondition(data); + }); +} + +interface BuildConditionOptions { + featured?: boolean; + locale?: string; + categoryId?: string; + tagId?: string; +} + +function buildCondition(data: any, options: BuildConditionOptions = {}) { + const { featured, locale, categoryId, tagId } = options; + + // Basic condition + let condition: boolean = !data.hidden; + + if (locale) { + condition = condition && data.language === locale; + } + + if (featured) { + condition = condition && data.featured; + } + + if (categoryId) { + condition = condition && data.category?.id === categoryId; + } + + if (tagId) { + condition = condition && data.tags.some((tag: CollectionEntry<"tags">) => tag.id === tagId); + } + + return condition; +} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..27e44a7 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,13 @@ +export * from "./extractFilenameAndExtension" +export * from "./generateOgImage" +export * from "./getAbsoluteBlogPostUrl" +export * from "./getBlogPostByIdAndLocale" +export * from "./getBlogPostSlug" +export * from "./getBlogPostUrl" +export * from "./getCategoryByLocale" +export * from "./getFilteredPostsCollection" +export * from "./getOgImageUrl" +export * from "./getPostImgTransitionName" +export * from "./getTagByLocale" +export * from "./removeTrailingSlash" +export * from "./slugifyStr" \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index d5e3c4d..b0717a4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "@i18n/*": ["src/i18n/*"], "@public/*": ["src/public/*"], "@layouts/*": ["src/layouts/*"], - "@utils/*": ["src/utils/*"], + "@utils": ["src/utils/index.ts"], "@config/*": ["src/config/*"], }, },