tags from strapi

This commit is contained in:
tmshv committed 2021-02-17 10:41:42 +03:00
1 parent 546c4ffa0e
commit 4f5f3bb9d7
3 files changed
+20 -20

No files matched your search

+9 -2
View File
@@ -1,5 +1,5 @@
import { getResizedUrl, imageSrc } from "@/lib/image";
import { IPage, PageCardDto, Token } from "@/types";
import { IPage, ITag, PageCardDto, Token } from "@/types";
import { asItem } from "./lib";
import { StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard } from "./types";
@@ -69,6 +69,13 @@ export function createPage(res: StrapiPage | StrapiPage[]): IPage {
return null
}
const tags: ITag[] = item.tags.map(tag => ({
id: tag.id,
name: tag.name,
slug: tag.slug,
href: `/tags/${tag.slug}`,
}))
return {
title: item.title,
description: item.excerpt,
@@ -91,7 +98,7 @@ export function createPage(res: StrapiPage | StrapiPage[]): IPage {
...createPageTokens(item.content)
.filter(Boolean),
],
tags: [],
tags,
// breadcrumb?: [],
featured: false,
}
+10 -18
View File
@@ -79,6 +79,15 @@ export type StrapiComponent =
| StrapiComponentDocument
| StrapiComponentEmbed
export type StrapiTag = {
id: number,
slug: string,
name: string,
// "page": 114,
// "created_at": "2021-01-31T20:38:39.373Z",
// "updated_at": "2021-02-17T07:37:54.749Z"
}
export type StrapiPage = {
id: number,
title: string,
@@ -90,24 +99,7 @@ export type StrapiPage = {
created_at: string,
updated_at: string,
content: StrapiComponent[],
// "tags": [
// {
// "id": 5,
// "slug": "hudozka",
// "name": "Художка",
// "page": 114,
// "created_at": "2021-01-31T20:38:39.373Z",
// "updated_at": "2021-02-04T04:04:34.943Z"
// },
// {
// "id": 6,
// "slug": "public-space",
// "name": "Среда",
// "page": 114,
// "created_at": "2021-01-31T20:38:39.722Z",
// "updated_at": "2021-02-04T04:04:34.943Z"
// }
// ],
tags: StrapiTag[],
// "breadcrumbs": [],
// "breadcrumbRelations": []
}
+1
View File
@@ -87,6 +87,7 @@ export interface IImage {
}
export interface ITag {
id: number
name: string
slug: string
href: string