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 { getResizedUrl, imageSrc } from "@/lib/image";
import { IPage, PageCardDto, Token } from "@/types"; import { IPage, ITag, PageCardDto, Token } from "@/types";
import { asItem } from "./lib"; import { asItem } from "./lib";
import { StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard } from "./types"; import { StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard } from "./types";
@@ -69,6 +69,13 @@ export function createPage(res: StrapiPage | StrapiPage[]): IPage {
return null return null
} }
const tags: ITag[] = item.tags.map(tag => ({
id: tag.id,
name: tag.name,
slug: tag.slug,
href: `/tags/${tag.slug}`,
}))
return { return {
title: item.title, title: item.title,
description: item.excerpt, description: item.excerpt,
@@ -91,7 +98,7 @@ export function createPage(res: StrapiPage | StrapiPage[]): IPage {
...createPageTokens(item.content) ...createPageTokens(item.content)
.filter(Boolean), .filter(Boolean),
], ],
tags: [], tags,
// breadcrumb?: [], // breadcrumb?: [],
featured: false, featured: false,
} }
+10 -18
View File
@@ -79,6 +79,15 @@ export type StrapiComponent =
| StrapiComponentDocument | StrapiComponentDocument
| StrapiComponentEmbed | 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 = { export type StrapiPage = {
id: number, id: number,
title: string, title: string,
@@ -90,24 +99,7 @@ export type StrapiPage = {
created_at: string, created_at: string,
updated_at: string, updated_at: string,
content: StrapiComponent[], content: StrapiComponent[],
// "tags": [ tags: StrapiTag[],
// {
// "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"
// }
// ],
// "breadcrumbs": [], // "breadcrumbs": [],
// "breadcrumbRelations": [] // "breadcrumbRelations": []
} }
+1
View File
@@ -87,6 +87,7 @@ export interface IImage {
} }
export interface ITag { export interface ITag {
id: number
name: string name: string
slug: string slug: string
href: string href: string