Add posts to latest story
This commit is contained in:
parent
7bb8a952ef
commit
6dd8a92318
8 changed files with 51 additions and 31 deletions
|
|
@ -29,12 +29,14 @@ function parseRegex<R extends { [key: string]: string }>(regex: RegExp) {
|
|||
* from `website` - a pre-parsed object containing the link and username.
|
||||
*/
|
||||
const websiteLinks = z.object({
|
||||
website: z
|
||||
.string()
|
||||
.url()
|
||||
.transform((link) => {
|
||||
link;
|
||||
}),
|
||||
website: z.object({ link: z.string().url() }).or(
|
||||
z
|
||||
.string()
|
||||
.url()
|
||||
.transform((link) => {
|
||||
link;
|
||||
}),
|
||||
),
|
||||
eka: z.object({ link: z.string().url(), username: z.string() }).or(
|
||||
z.string().transform((link, ctx) => {
|
||||
const { username } = parseRegex<{ username: string }>(
|
||||
|
|
@ -189,6 +191,12 @@ const publishedContent = z.object({
|
|||
)(link, ctx);
|
||||
return { link, postId };
|
||||
}),
|
||||
twitter: z.string().transform((link, ctx) => {
|
||||
const { user, postId } = parseRegex<{ user: string; postId: string }>(
|
||||
/^(?:https?:\/\/)(?:www\.)?(?:twitter\.com|x\.com)\/(?<user>[a-zA-Z0-9_-]+)\/status\/(?<postId>[1-9]\d*)\/?$/,
|
||||
)(link, ctx);
|
||||
return { link, user, postId };
|
||||
}),
|
||||
bluesky: z.string().transform((link, ctx) => {
|
||||
const { user, postId } = parseRegex<{ user: string; postId: string }>(
|
||||
/^(?:https?:\/\/)bsky\.app\/profile\/(?<user>(?:[a-zA-Z0-9_-]+\.)+[a-z]+)\/post\/(?<postId>[a-z0-9]+)\/?$/,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue