t_wの輪郭

Feedlyでフォローするボタン

供養

2023/4/1 8:15:00
const graphql_search_post_result = await API.graphql({
  query: searchPosts,
  variables: {
    filter: { or: [{ body_html: { match: query } }, { name: { match: query } }] },
    limit: 100,
    // sort: { direction: "desc", field: "name" },
  },
  authMode: "API_KEY",
  authToken: awsExports.aws_appsync_apiKey
}) as GraphQLResult<SearchPostsQuery>
const posts_search: Post[] = (graphql_search_post_result.data?.searchPosts?.items.filter(post => post) ?? []) as Post[];

const posts_deduped_sorted = [...new Map(search_result.map(p=>[p.id, p])).values()]
  .sort((a, b) => Date.parse(b.updatedOn) - Date.parse(a.updatedOn))
.sort((a,b)=>(b.name==query ? 1 : 0) - (a.name==query ? 1 : 0))
set_posts(posts_deduped_sorted);