├── public ├── blog-placeholder-1.jpg ├── blog-placeholder-2.jpg ├── blog-placeholder-3.jpg ├── blog-placeholder-4.jpg ├── blog-placeholder-5.jpg ├── fonts │ ├── atkinson-bold.woff │ └── atkinson-regular.woff ├── blog-placeholder-about.jpg └── favicon.svg ├── src ├── pages │ ├── index.astro │ ├── rss.xml.js │ ├── 404.astro │ ├── [lang] │ │ ├── blog │ │ │ ├── [slug].astro │ │ │ └── pages │ │ │ │ └── [page].astro │ │ ├── projects │ │ │ ├── [slug].astro │ │ │ └── pages │ │ │ │ └── [page].astro │ │ ├── series │ │ │ ├── index.astro │ │ │ └── [series] │ │ │ │ └── [...page].astro │ │ ├── tags │ │ │ ├── index.astro │ │ │ └── [tag] │ │ │ │ └── [...page].astro │ │ └── archive │ │ │ └── index.astro │ ├── en │ │ ├── about.astro │ │ └── index.astro │ └── es │ │ ├── about.astro │ │ └── index.astro ├── content │ ├── blog │ │ ├── draft.md │ │ ├── hidden-post.md │ │ ├── en │ │ │ └── multi-lang-test.md │ │ ├── es │ │ │ └── multi-lang-test.md │ │ ├── test-tables.md │ │ ├── using-mdx.mdx │ │ ├── second-post.md │ │ ├── third-post.md │ │ ├── first-post.md │ │ └── markdown-style-guide.md │ ├── project │ │ ├── es │ │ │ ├── project-1.md │ │ │ ├── project-4.md │ │ │ ├── project-3.md │ │ │ └── project-2.md │ │ ├── project-1.md │ │ ├── project-4.md │ │ ├── project-3.md │ │ └── project-2.md │ └── config.ts ├── env.d.ts ├── components │ ├── FormattedDate.astro │ ├── HeaderLink.astro │ ├── TableOfContentsHeading.astro │ ├── SocialMediaLinks.astro │ ├── Pagination.astro │ ├── Footer.astro │ ├── BackToTopBtn.astro │ ├── blog │ │ ├── PostPreviewA.astro │ │ └── PostPreviewB.astro │ ├── SelectLanguage.astro │ ├── CopyBtn.astro │ ├── BaseHead.astro │ ├── ThemeToggle.astro │ ├── TableOfContents.astro │ ├── Search.astro │ └── Header.astro ├── utils │ ├── remark-reading-time.mjs │ ├── date.ts │ ├── series.ts │ ├── tags.ts │ ├── frontmatter.ts │ ├── index.ts │ ├── i18n.ts │ └── post.ts ├── layouts │ ├── Sidebar.astro │ ├── Base.astro │ ├── GenericPost.astro │ ├── Project.astro │ └── BlogPost.astro ├── styles │ ├── search.css │ └── global.css ├── consts.ts └── i18n │ ├── ui.ts │ └── nav.ts ├── .vscode ├── extensions.json └── launch.json ├── .gitignore ├── tsconfig.json ├── tailwind.config.mjs ├── package.json ├── astro.config.mjs ├── LICENSE └── README.md /public/blog-placeholder-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-1.jpg -------------------------------------------------------------------------------- /public/blog-placeholder-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-2.jpg -------------------------------------------------------------------------------- /public/blog-placeholder-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-3.jpg -------------------------------------------------------------------------------- /public/blog-placeholder-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-4.jpg -------------------------------------------------------------------------------- /public/blog-placeholder-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-5.jpg -------------------------------------------------------------------------------- /public/fonts/atkinson-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/fonts/atkinson-bold.woff -------------------------------------------------------------------------------- /public/blog-placeholder-about.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/blog-placeholder-about.jpg -------------------------------------------------------------------------------- /public/fonts/atkinson-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kirontoo/astro-theme-cody/HEAD/public/fonts/atkinson-regular.woff -------------------------------------------------------------------------------- /src/pages/index.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { DEFAULT_LANG } from "src/consts"; 3 | return Astro.redirect(`/${DEFAULT_LANG}/`); 4 | --- 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["astro-build.astro-vscode", "unifiedjs.vscode-mdx"], 3 | "unwantedRecommendations": [] 4 | } 5 | -------------------------------------------------------------------------------- /src/content/blog/draft.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test Draft Post" 3 | description: "This is a test post for draft post." 4 | pubDate: 2024-05-24 5 | draft: true 6 | --- 7 | 8 | -------------------------------------------------------------------------------- /src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | declare module "@pagefind/default-ui" { 4 | declare class PagefindUI { 5 | constructor(arg: unknown); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/content/blog/hidden-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test Hidden Post" 3 | description: "This is a test post for hidden post." 4 | pubDate: 2024-05-24 5 | hide: true 6 | --- 7 | 8 | This post is supposed to be hidden from `/blog` but not from `/archive`. 9 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "command": "./node_modules/.bin/astro dev", 6 | "name": "Development server", 7 | "request": "launch", 8 | "type": "node-terminal" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/content/blog/en/multi-lang-test.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Test Post in English' 3 | description: 'Lorem ipsum dolor sit amet' 4 | pubDate: 'Sep 26 2024' 5 | tags: ["multi-lang", "test"] 6 | updatedDate: 'Sep 26 2024' 7 | series: "example" 8 | --- 9 | 10 | Is in English. 11 | -------------------------------------------------------------------------------- /src/content/blog/es/multi-lang-test.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Test Post in Spanish' 3 | description: 'Lorem ipsum dolor sit amet' 4 | pubDate: 'Sep 26 2024' 5 | tags: ["multi-lang", "test"] 6 | updatedDate: 'Sep 26 2024' 7 | series: "example" 8 | --- 9 | 10 | Es en espanol. 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist/ 3 | # generated types 4 | .astro/ 5 | 6 | # dependencies 7 | node_modules/ 8 | 9 | # logs 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | # pagefind 16 | public/pagefind/ 17 | 18 | # environment variables 19 | .env 20 | .env.production 21 | 22 | # macOS-specific files 23 | .DS_Store 24 | -------------------------------------------------------------------------------- /src/pages/rss.xml.js: -------------------------------------------------------------------------------- 1 | import rss from '@astrojs/rss'; 2 | import { getCollection } from 'astro:content'; 3 | import { siteConfig } from '../consts'; 4 | 5 | export async function GET(context) { 6 | const posts = await getCollection('blog'); 7 | return rss({ 8 | title: siteConfig.title, 9 | description: siteConfig.description, 10 | site: context.site, 11 | items: posts.map((post) => ({ 12 | ...post.data, 13 | link: `/blog/${post.slug}/`, 14 | })), 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /src/components/FormattedDate.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import type { HTMLAttributes } from "astro/types"; 3 | import { getFormattedDate } from "@/utils"; 4 | 5 | type Props = HTMLAttributes<"time"> & { 6 | date: Date; 7 | dateTimeOptions?: Intl.DateTimeFormatOptions; 8 | locale?: string; 9 | }; 10 | 11 | const { date, dateTimeOptions, locale, ...attrs } = Astro.props; 12 | const postDate = getFormattedDate(date, dateTimeOptions, locale); 13 | --- 14 | 15 | 18 | -------------------------------------------------------------------------------- /src/utils/remark-reading-time.mjs: -------------------------------------------------------------------------------- 1 | import getReadingTime from 'reading-time'; 2 | import { toString } from 'mdast-util-to-string'; 3 | 4 | // https://docs.astro.build/en/recipes/reading-time/#recipe 5 | export function remarkReadingTime() { 6 | return function (tree, { data }) { 7 | const textOnPage = toString(tree); 8 | const readingTime = getReadingTime(textOnPage); 9 | // readingTime.text will give us minutes read as a friendly string, 10 | // i.e. "3 min read" 11 | data.astro.frontmatter.minutesRead = readingTime.text; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "astro/tsconfigs/strict", 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "strictNullChecks": true, 6 | "paths": { 7 | "@/utils": [ 8 | "src/utils/index.ts" 9 | ], 10 | "@/components/*": [ 11 | "src/components/*.astro" 12 | ], 13 | "@/layouts/*": [ 14 | "src/layouts/*.astro" 15 | ], 16 | "@/i18n/*": [ 17 | "src/i18n/*.ts" 18 | ], 19 | "@/styles/*": [ 20 | "src/styles/*.css" 21 | ], 22 | } 23 | }, 24 | "include": [ 25 | "src", 26 | "*.ts" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /src/components/HeaderLink.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import type { HTMLAttributes } from 'astro/types'; 3 | 4 | type Props = HTMLAttributes<'a'>; 5 | 6 | const { href, class: className, ...props } = Astro.props; 7 | 8 | const { pathname } = Astro.url; 9 | const isActive = href === pathname || href === pathname.replace(/\/$/, ''); 10 | --- 11 | 12 | 13 | 14 | 15 | 16 | 28 | -------------------------------------------------------------------------------- /src/utils/date.ts: -------------------------------------------------------------------------------- 1 | const dateOptions = { 2 | locale: "en-GB", 3 | options: { 4 | day: "numeric", 5 | month: "short", 6 | year: "numeric", 7 | } 8 | }; 9 | 10 | const dateFormat = new Intl.DateTimeFormat( 11 | dateOptions.locale, 12 | dateOptions.options as Intl.DateTimeFormatOptions 13 | ); 14 | 15 | export function getFormattedDate( 16 | date: string | number | Date, 17 | options?: Intl.DateTimeFormatOptions, 18 | locale?: string, 19 | ) { 20 | if (typeof options !== "undefined") { 21 | return new Date(date).toLocaleDateString(locale ?? dateOptions.locale, options); 22 | } 23 | 24 | return dateFormat.format(new Date(date)); 25 | } 26 | -------------------------------------------------------------------------------- /src/utils/series.ts: -------------------------------------------------------------------------------- 1 | import type { CollectionEntry } from "astro:content"; 2 | 3 | export function getAllSeries(posts: Array>) { 4 | return posts.flatMap(({data}) => ( data.series ? [...data.series ] : [] )); 5 | } 6 | 7 | export function getUniqueSeries(posts: Array>) { 8 | return [...new Set(getAllSeries(posts))]; 9 | } 10 | 11 | export function getUniqueSeriesWithCount( 12 | posts: Array>, 13 | ): Array<[string, number]> { 14 | return [ 15 | ...getAllSeries(posts).reduce( 16 | (acc, t) => acc.set(t, (acc.get(t) || 0) + 1), 17 | new Map(), 18 | ), 19 | ].sort((a, b) => b[1] - a[1]); 20 | } 21 | -------------------------------------------------------------------------------- /tailwind.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], 4 | darkMode: "class", 5 | theme: { 6 | fontFamily: { 7 | 'mono': ['Space Mono', 'monospace'] 8 | }, 9 | extend: { 10 | colors: { 11 | bgColor: "var(--theme-bg)", 12 | textColor: "var(--theme-text)", 13 | link: "var(--theme-link)", 14 | accent: "var(--theme-accent)", 15 | "accent-2": "var(--theme-accent-2)", 16 | surface: "var(--theme-surface)", 17 | quote: "var(--theme-quote)", 18 | highlight: "var(--theme-highlight)" 19 | }, 20 | } 21 | }, 22 | plugins: [ 23 | require('@tailwindcss/typography'), 24 | ], 25 | } 26 | -------------------------------------------------------------------------------- /src/components/TableOfContentsHeading.astro: -------------------------------------------------------------------------------- 1 | --- 2 | // TableOfContentsHeading.astro 3 | import type { MarkdownHeading } from "astro"; 4 | const { heading } = Astro.props; 5 | --- 6 | 7 |
  • 8 | 9 | {heading.text} 10 | 11 | { 12 | heading.subheadings.length > 0 && ( 13 |
      14 | {heading.subheadings.map((subheading: MarkdownHeading[]) => ( 15 | 16 | ))} 17 |
    18 | ) 19 | } 20 |
  • 21 | 22 | 32 | 33 | -------------------------------------------------------------------------------- /public/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /src/content/project/es/project-1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 1' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Apr 03 2023' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS'] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | -------------------------------------------------------------------------------- /src/content/project/es/project-4.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 4' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Jun 08 2003' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS'] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | -------------------------------------------------------------------------------- /src/content/project/project-1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 1' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Apr 03 2023' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS'] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | -------------------------------------------------------------------------------- /src/content/project/project-4.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 4' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Jun 08 2003' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS'] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | -------------------------------------------------------------------------------- /src/utils/tags.ts: -------------------------------------------------------------------------------- 1 | import type { CollectionEntry } from "astro:content"; 2 | 3 | // https://github.com/chrismwilliams/astro-theme-cactus/blob/a85e0e559d3f92b32e73990486c0574b2b733227/src/utils/post.ts 4 | export function getAllTags(posts: Array>) { 5 | return posts.flatMap(({data}) => ( data.tags ? [...data.tags ] : [] )); 6 | } 7 | 8 | export function getUniqueTags(posts: Array>) { 9 | return [...new Set(getAllTags(posts))]; 10 | } 11 | 12 | export function getUniqueTagsWithCount( 13 | posts: Array>, 14 | ): Array<[string, number]> { 15 | return [ 16 | ...getAllTags(posts).reduce( 17 | (acc, t) => acc.set(t, (acc.get(t) || 0) + 1), 18 | new Map(), 19 | ), 20 | ].sort((a, b) => b[1] - a[1]); 21 | } 22 | -------------------------------------------------------------------------------- /src/content/project/project-3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 3' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Mar 03 2023' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Reactjs', 'Typescript', "Mongo"] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | order: 1 13 | --- 14 | 15 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 16 | -------------------------------------------------------------------------------- /src/content/project/es/project-3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 3' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Mar 03 2023' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Reactjs', 'Typescript', "Mongo"] 10 | website: https://github.com/kirontoo/astro-theme-cody 11 | github: https://github.com/kirontoo/astro-theme-cody 12 | order: 1 13 | --- 14 | 15 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 16 | -------------------------------------------------------------------------------- /src/components/SocialMediaLinks.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { Icon } from "astro-icon"; 3 | import { SOCIAL_LINKS } from "src/consts.ts"; 4 | --- 5 | 6 |
    7 | 30 |
    31 | -------------------------------------------------------------------------------- /src/content/project/project-2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 2' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Aug 13 2022' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS', 'tailwind'] website: https://github.com/kirontoo/astro-theme-cody 10 | github: https://github.com/kirontoo/astro-theme-cody 11 | order: 2 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | 16 | ## hello 17 | -------------------------------------------------------------------------------- /src/content/project/es/project-2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Project 2' 3 | description: 'Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci' 4 | pubDate: 'Aug 13 2022' 5 | heroImage: 6 | url: '/blog-placeholder-about.jpg' 7 | alt: 'GitHub wallpaper' 8 | platform: Web 9 | stack: ['Astro', 'JS', 'tailwind'] website: https://github.com/kirontoo/astro-theme-cody 10 | github: https://github.com/kirontoo/astro-theme-cody 11 | order: 2 12 | --- 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus a tortor at molestie. Sed pellentesque leo auctor, auctor lorem nec, venenatis risus. Vivamus commodo ipsum vitae orci finibus, vel porta nunc viverra. In hac habitasse platea dictumst. Nunc pretium, ligula ultricies consequat sollicitudin, enim ex ullamcorper nisl. 15 | 16 | ## hello 17 | -------------------------------------------------------------------------------- /src/utils/frontmatter.ts: -------------------------------------------------------------------------------- 1 | import type { CollectionEntry } from "astro:content"; 2 | 3 | // should only be used with frontmatter arrays 4 | export function getAllPostsByProperty(prop: "series" | "tags", posts: Array>) { 5 | return posts.flatMap(({ data }) => { 6 | return data[prop] ?? []; 7 | }) 8 | } 9 | 10 | export function getUniqueByProperty(prop: "series" | "tags", posts: Array>) { 11 | return [...new Set(getAllPostsByProperty(prop, posts))]; 12 | } 13 | 14 | export function getUniqueWithCountByProperty( 15 | prop: "series" | "tags", 16 | posts: Array>, 17 | ): Array<[string, number]> { 18 | return [ 19 | ...getAllPostsByProperty(prop, posts).reduce( 20 | (acc, t) => acc.set(t, (acc.get(t) || 0) + 1), 21 | new Map(), 22 | ), 23 | ].sort((a, b) => b[1] - a[1]); 24 | } 25 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export { getFormattedDate } from "./date"; 2 | export { remarkReadingTime } from "./remark-reading-time.mjs"; 3 | export { 4 | getAllTags, 5 | getUniqueTags, 6 | getUniqueTagsWithCount, 7 | } from "./tags"; 8 | 9 | export { 10 | getAllPosts, 11 | getPostsByTag, 12 | getPostsBySeries, 13 | sortMDByDate, 14 | sortMDByPinned, 15 | filterByLanguage, 16 | getSlugFromCollectionEntry 17 | } from "./post"; 18 | 19 | export { 20 | getAllSeries, 21 | getUniqueSeries, 22 | getUniqueSeriesWithCount, 23 | } from "./series" 24 | 25 | export { 26 | getAllPostsByProperty, 27 | getUniqueByProperty, 28 | getUniqueWithCountByProperty, 29 | } from "./frontmatter" 30 | 31 | export { 32 | type SupportedLanguage, 33 | getSupportedLanguages, 34 | isValidLanguageCode, 35 | getLangFromUrl, 36 | getLangFromSlug, 37 | useNavTranslations, 38 | useUITranslations 39 | } from "./i18n" 40 | -------------------------------------------------------------------------------- /src/layouts/Sidebar.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import BaseHead from '../components/BaseHead.astro'; 3 | import Header from '../components/Header.astro' 4 | import Footer from '../components/Footer.astro'; 5 | import { siteConfig } from "../consts.ts"; 6 | 7 | interface Props { 8 | title?: string; 9 | description?: string; 10 | image?: string; 11 | articleDate?: string 12 | } 13 | 14 | const { 15 | title = siteConfig.title, 16 | description = siteConfig.description, 17 | image, 18 | articleDate 19 | } = Astro.props; 20 | 21 | --- 22 | 23 | 24 | 25 | 26 | 27 | 28 |
    29 |
    30 | 31 | 32 |
    33 |