double qutes eslint rule
This commit is contained in:
1 parent
2e517cc7f7
commit
85bc8c4af5
57 files changed
+370
-366
No files matched your search
+20
-20
@@ -1,7 +1,7 @@
|
||||
import { IMenu, IPage, ITag, PageCardDto, Pic, Token } from "@/types"
|
||||
import { asItem } from "./lib"
|
||||
import { StrapiComponentEmbed, StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard, StrapiTag, StrapiMedia, StrapiMenu } from "./types"
|
||||
import { typograf, markdownToHtml } from 'src/lib/text'
|
||||
import { typograf, markdownToHtml } from "src/lib/text"
|
||||
import { encodeImageToBlurhash } from "./image"
|
||||
|
||||
const md = (text: string) => typograf(markdownToHtml(text))
|
||||
@@ -19,7 +19,7 @@ export function isYoutubeUrl(url: string): boolean {
|
||||
export function createEmbed(component: StrapiComponentEmbed): Token {
|
||||
if (isYoutubeUrl(component.src)) {
|
||||
return {
|
||||
token: 'youtube',
|
||||
token: "youtube",
|
||||
data: {
|
||||
url: component.src,
|
||||
},
|
||||
@@ -27,39 +27,39 @@ export function createEmbed(component: StrapiComponentEmbed): Token {
|
||||
}
|
||||
|
||||
return {
|
||||
token: 'html',
|
||||
token: "html",
|
||||
data: `<iframe src="${component.src}" width="100%" height="480" frameborder="0"></iframe>`,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createPageToken(component: StrapiComponent): Promise<Token> {
|
||||
switch (component.__component) {
|
||||
case 'hudozka.text': {
|
||||
case "hudozka.text": {
|
||||
return {
|
||||
token: 'html',
|
||||
token: "html",
|
||||
data: md(component.text),
|
||||
}
|
||||
}
|
||||
|
||||
case 'hudozka.image': {
|
||||
case "hudozka.image": {
|
||||
const data = await createPicFromMedia(component.media, {
|
||||
alternativeText: component.caption,
|
||||
caption: component.caption,
|
||||
})
|
||||
|
||||
return {
|
||||
token: 'image',
|
||||
token: "image",
|
||||
wide: component.wide,
|
||||
data,
|
||||
}
|
||||
}
|
||||
|
||||
case 'hudozka.document': {
|
||||
case "hudozka.document": {
|
||||
return {
|
||||
token: 'file',
|
||||
token: "file",
|
||||
data: {
|
||||
url: component.media.url,
|
||||
slug: 'jopa',
|
||||
slug: "jopa",
|
||||
image_url: component.media.url,
|
||||
file_url: component.media.url,
|
||||
title: component.title,
|
||||
@@ -70,17 +70,17 @@ export async function createPageToken(component: StrapiComponent): Promise<Token
|
||||
}
|
||||
}
|
||||
|
||||
case 'hudozka.embed': {
|
||||
case "hudozka.embed": {
|
||||
return createEmbed(component)
|
||||
}
|
||||
|
||||
case 'hudozka.card-grid': {
|
||||
case "hudozka.card-grid": {
|
||||
const items = await Promise.all(component.items
|
||||
.filter(Boolean)
|
||||
.map(createCardGrid)
|
||||
)
|
||||
return {
|
||||
token: 'grid',
|
||||
token: "grid",
|
||||
data: {
|
||||
items,
|
||||
},
|
||||
@@ -89,7 +89,7 @@ export async function createPageToken(component: StrapiComponent): Promise<Token
|
||||
|
||||
default:
|
||||
return {
|
||||
token: 'text',
|
||||
token: "text",
|
||||
data: ` ${JSON.stringify(component)}`,
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export function createMenu(res: StrapiMenu): IMenu[] {
|
||||
}))
|
||||
|
||||
return [{
|
||||
href: '/',
|
||||
href: "/",
|
||||
name: res.homeLabel,
|
||||
}, ...items]
|
||||
}
|
||||
@@ -130,12 +130,12 @@ export async function createPage(res: StrapiPage | StrapiPage[]): Promise<IPage
|
||||
id: `${item.id}`,
|
||||
url: item.slug,
|
||||
|
||||
data: '',
|
||||
date: '',
|
||||
data: "",
|
||||
date: "",
|
||||
cover,
|
||||
tokens: [
|
||||
{
|
||||
token: 'html',
|
||||
token: "html",
|
||||
data: md(`# ${item.title}`),
|
||||
},
|
||||
|
||||
@@ -148,7 +148,7 @@ export async function createPage(res: StrapiPage | StrapiPage[]): Promise<IPage
|
||||
}
|
||||
|
||||
function isCardFeatured(card: StrapiPageCard): boolean {
|
||||
return card.layout === 'big' || card.layout === 'medium'
|
||||
return card.layout === "big" || card.layout === "medium"
|
||||
}
|
||||
|
||||
export async function getCoverImage(media?: StrapiMedia): Promise<Pic> {
|
||||
@@ -157,7 +157,7 @@ export async function getCoverImage(media?: StrapiMedia): Promise<Pic> {
|
||||
}
|
||||
|
||||
return {
|
||||
src: 'https://hudozkacdn.tmshv.com/main_fad9fdf29a.jpg',
|
||||
src: "https://hudozkacdn.tmshv.com/main_fad9fdf29a.jpg",
|
||||
width: 1920,
|
||||
height: 1858,
|
||||
// alt: '',
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ export async function encodeImageToBlurhash(url: string) {
|
||||
const t = sharp(buffer)
|
||||
.raw()
|
||||
.resize(8, 8, { fit: "inside" })
|
||||
.toFormat('jpeg')
|
||||
.toFormat("jpeg")
|
||||
|
||||
const { data } = await t.toBuffer({ resolveWithObject: true })
|
||||
|
||||
return `data:image/jpeg;base64,${data.toString('base64')}`
|
||||
return `data:image/jpeg;base64,${data.toString("base64")}`
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ export function asItem<T>(value: T | T[]) {
|
||||
}
|
||||
|
||||
export function paramsToSlug(parts: string | string[]): string {
|
||||
const slug = asArray(parts).join('/')
|
||||
const slug = asArray(parts).join("/")
|
||||
|
||||
return `/${slug}`
|
||||
}
|
||||
+2
-2
@@ -128,8 +128,8 @@ export type StrapiMenu = {
|
||||
}
|
||||
|
||||
export type StrapiPageCard = {
|
||||
__component: 'hudozka.page-card',
|
||||
__component: "hudozka.page-card",
|
||||
id: number,
|
||||
page: StrapiPage,
|
||||
layout: 'small' | 'medium' | 'big',
|
||||
layout: "small" | "medium" | "big",
|
||||
}
|
||||
Reference in new issue
Block a user