-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/integration-konfidency
- Loading branch information
Showing
28 changed files
with
2,157 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* @title BlogRelatedPosts | ||
* @description Retrieves a list of blog related posts. | ||
* | ||
* @param props - The props for the blog related post list. | ||
* @param req - The request object. | ||
* @param ctx - The application context. | ||
* @returns A promise that resolves to an array of blog related posts. | ||
*/ | ||
import { RequestURLParam } from "../../website/functions/requestToParam.ts"; | ||
import { AppContext } from "../mod.ts"; | ||
import { BlogPost, SortBy } from "../types.ts"; | ||
import handlePosts, { slicePosts } from "../utils/handlePosts.ts"; | ||
import { getRecordsByPath } from "../utils/records.ts"; | ||
|
||
const COLLECTION_PATH = "collections/blog/posts"; | ||
const ACCESSOR = "post"; | ||
|
||
export interface Props { | ||
/** | ||
* @title Items per page | ||
* @description Number of posts per page to display. | ||
*/ | ||
count?: number; | ||
/** | ||
* @title Page query parameter | ||
* @description The current page number. Defaults to 1. | ||
*/ | ||
page?: number; | ||
/** | ||
* @title Category Slug | ||
* @description Filter by a specific category slug. | ||
*/ | ||
slug?: RequestURLParam | string[]; | ||
/** | ||
* @title Page sorting parameter | ||
* @description The sorting option. Default is "date_desc" | ||
*/ | ||
sortBy?: SortBy; | ||
/** | ||
* @description Overrides the query term at url | ||
*/ | ||
query?: string; | ||
/** | ||
* @title Exclude Post Slug | ||
* @description Excludes a post slug from the list | ||
*/ | ||
excludePostSlug?: RequestURLParam | string; | ||
} | ||
|
||
/** | ||
* @title BlogRelatedPosts | ||
* @description Retrieves a list of blog related posts. | ||
* | ||
* @param props - The props for the blog related post list. | ||
* @param req - The request object. | ||
* @param ctx - The application context. | ||
* @returns A promise that resolves to an array of blog related posts. | ||
*/ | ||
|
||
export type BlogRelatedPosts = BlogPost[] | null; | ||
|
||
export default async function BlogRelatedPosts( | ||
{ page, count, slug, sortBy, query, excludePostSlug }: Props, | ||
req: Request, | ||
ctx: AppContext, | ||
): Promise<BlogRelatedPosts> { | ||
const url = new URL(req.url); | ||
const postsPerPage = Number(count ?? url.searchParams.get("count") ?? 12); | ||
const pageNumber = Number(page ?? url.searchParams.get("page") ?? 1); | ||
const pageSort = sortBy ?? (url.searchParams.get("sortBy") as SortBy) ?? | ||
"date_desc"; | ||
const term = query ?? url.searchParams.get("q") ?? undefined; | ||
|
||
const posts = await getRecordsByPath<BlogPost>( | ||
ctx, | ||
COLLECTION_PATH, | ||
ACCESSOR, | ||
); | ||
|
||
const handledPosts = handlePosts( | ||
posts, | ||
pageSort, | ||
slug, | ||
term, | ||
excludePostSlug, | ||
); | ||
|
||
if (!handledPosts) { | ||
return null; | ||
} | ||
|
||
const slicedPosts = slicePosts(handledPosts, pageNumber, postsPerPage); | ||
|
||
return slicedPosts.length > 0 ? slicedPosts : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, preview } from "../../google-sheets/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,5 @@ | |
"jsx": "react-jsx", | ||
"jsxImportSource": "preact" | ||
}, | ||
"version": "0.64.10" | ||
"version": "0.64.18" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AppContext } from "../mod.ts"; | ||
|
||
export default function doc(_: null, __: Request, ctx: AppContext) { | ||
return ctx.doc; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// DO NOT EDIT. This file is generated by deco. | ||
// This file SHOULD be checked into source version control. | ||
// This file is automatically updated during development when running `dev.ts`. | ||
|
||
import * as $$$0 from "./loaders/doc.ts"; | ||
|
||
const manifest = { | ||
"loaders": { | ||
"google-sheets/loaders/doc.ts": $$$0, | ||
}, | ||
"name": "google-sheets", | ||
"baseUrl": import.meta.url, | ||
}; | ||
|
||
export type Manifest = typeof manifest; | ||
|
||
export default manifest; |
Oops, something went wrong.