resolve conflicts

This commit is contained in:
jinhojang6 2023-05-14 17:36:29 +09:00 committed by Jinho Jang
parent 3e5e136be5
commit 9cbda2ba78
11 changed files with 103 additions and 12 deletions

View File

@ -38,6 +38,7 @@
"graphql-request": "^6.0.0", "graphql-request": "^6.0.0",
"next": "13.3.0", "next": "13.3.0",
"react": "18.2.0", "react": "18.2.0",
"react-blurhash": "^0.3.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-imgix": "^9.7.0", "react-imgix": "^9.7.0",
"typescript": "5.0.4" "typescript": "5.0.4"

View File

@ -12,6 +12,7 @@ import {
import { Authors } from '../Authors' import { Authors } from '../Authors'
import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types' import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types'
import { Tags } from '@/components/Tags' import { Tags } from '@/components/Tags'
import { ResponsiveImage } from '../ResponsiveImage/ResponsiveImage'
export enum PostImageRatio { export enum PostImageRatio {
PORTRAIT = 'portrait', PORTRAIT = 'portrait',
@ -121,7 +122,8 @@ export default function Post({
if (postType === 'body') { if (postType === 'body') {
return ( return (
<ThumbnailContainer aspectRatio={aspectRatio}> <ThumbnailContainer aspectRatio={aspectRatio}>
<Thumbnail fill src={coverImage.url} alt={coverImage.alt} /> <ResponsiveImage data={coverImage} height={'458px'} />
{/*<Thumbnail fill src={coverImage.url} alt={coverImage.alt} />*/}
</ThumbnailContainer> </ThumbnailContainer>
) )
} else { } else {
@ -198,6 +200,7 @@ const ThumbnailContainer = styled.div<{
width: 100%; width: 100%;
height: 100%; height: 100%;
max-height: 458px; // temporary max-height based on the Figma design's max height max-height: 458px; // temporary max-height based on the Figma design's max height
overflow: hidden;
` `
const Thumbnail = styled(Image)` const Thumbnail = styled(Image)`

View File

@ -1,22 +1,61 @@
import React from 'react' import React, { useState } from 'react'
import Image from 'next/image' import Image from 'next/image'
import { UnbodyImageBlock } from '@/lib/unbody/unbody.types' import { UnbodyImageBlock } from '@/lib/unbody/unbody.types'
import Imgix from 'react-imgix' import Imgix from 'react-imgix'
import styled from '@emotion/styled'
import { Blurhash } from 'react-blurhash'
type Props = { type Props = {
data: UnbodyImageBlock data: UnbodyImageBlock
height?: number | string
} }
export const ResponsiveImage = ({ data }: Props) => { export const ResponsiveImage = ({ data, height = '100%' }: Props) => {
const [loaded, setLoaded] = useState(false)
return ( return (
<div <Container
style={{ style={{
position: 'relative', paddingTop: `calc(${data.height / data.width} * ${height})`,
width: '100%',
paddingTop: `${(data.height / data.width) * 100}%`,
}} }}
> >
<Imgix src={data.url} /> <img src={`${data.url}?blur=10&w=10`} />
</div> {/*<Blurhash*/}
{/* hash={`e8I#x__3~qD%IU~q%MRQRjtQWB%M9FxuxuNG%MWBoLayof%Mt7Rj-;`}*/}
{/* width={"100%"}*/}
{/* height={"100%"}*/}
{/*/>*/}
<Imgix imgixParams={{ fit: 'clip' }} src={data.url} />
</Container>
) )
} }
const Container = styled.div`
position: relative;
width: 100%;
padding-top: 100%;
overflow: hidden;
object-fit: cover;
filter: grayscale(100%);
transition: filter 0.1s ease-in-out;
:hover {
filter: grayscale(0%);
}
> * {
position: absolute !important;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
&:last-of-type {
//opacity: 0.5;
//&.loaded{
// opacity: 1;
//}
}
}
`

View File

@ -0,0 +1,8 @@
export const ArticleBlocksOrders = {
title: 0,
subtitle: 1,
summary: 2,
tags: 3,
mentions: 4,
cover: 5,
}

View File

@ -20,6 +20,10 @@ export type TextBlockEnhanced = UnbodyTextBlock & {
document?: Array<GoogleDocEnhanced> document?: Array<GoogleDocEnhanced>
} }
export type ImageBlockEnhanced = UnbodyImageBlock & {
blurhash?: string
}
export * as UnbodyGraphQl from './unbody-content.types' export * as UnbodyGraphQl from './unbody-content.types'
export type UnbodyGraphQlResponse<T> = { export type UnbodyGraphQlResponse<T> = {

View File

@ -1,8 +1,18 @@
import { UnbodyGetFilters } from './unbody.types' import { ImageBlockEnhanced, UnbodyGetFilters } from './unbody.types'
import { UnbodyGraphQl } from './unbody-content.types' import { UnbodyGraphQl } from './unbody-content.types'
import axios from 'axios'
const operators = Object.values(UnbodyGraphQl.Filters.WhereOperatorEnum) const operators = Object.values(UnbodyGraphQl.Filters.WhereOperatorEnum)
// export const enhanceImageBlock = async (block: UnbodyGraphQl.ImageBlock): Promise<ImageBlockEnhanced> => {
// try{
// const blurHash = axios.get(`${block.url}?fm=blurhash`).then((res) => res.data)
// console.log(blurHash)
// }catch(e){
// console.log(e)
// }
// }
export const parseFilterArgs = (args: UnbodyGetFilters = {}): string => { export const parseFilterArgs = (args: UnbodyGetFilters = {}): string => {
const parse = (obj: any): string | number => { const parse = (obj: any): string | number => {
if (typeof obj === 'number') { if (typeof obj === 'number') {

View File

@ -48,14 +48,26 @@ export default function App({ Component, pageProps }: AppLayoutProps) {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
#__next { #__next {
max-width: 1440px; max-width: 1440px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
:root { :root {
--lpe-nav-rendered-height: ${uiConfigs.navbarRenderedHeight}px; --lpe-nav-rendered-height: ${uiConfigs.navbarRenderedHeight}px;
} }
//.lazyload,
//img.lazyloading {
// opacity: 0;
// transition: opacity 4000ms;
//}
//
//img.lazyloaded {
// opacity: 1;
//}
`} `}
/> />
<SearchBarProvider> <SearchBarProvider>

View File

@ -25,6 +25,8 @@ export const getHomePagePostsQuery = (args: UnbodyGetFilters = defaultArgs) =>
url url
alt alt
order order
width
height
__typename __typename
} }
} }

View File

@ -17,6 +17,8 @@ export const getSearchArticlesQuery = (args: UnbodyGetFilters = defaultArgs) =>
url url
alt alt
order order
width
height
__typename __typename
} }
} }

View File

@ -8,6 +8,7 @@ import {
import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types' import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types'
import { isAuthorsParagraph } from './html.utils' import { isAuthorsParagraph } from './html.utils'
import { similarity } from './string.utils' import { similarity } from './string.utils'
import { ArticleBlocksOrders } from '@/configs/data.configs'
function hasClassName(inputString: string, className: string) { function hasClassName(inputString: string, className: string) {
const regex = new RegExp(`class\\s*=\\s*"[^"]*\\b${className}\\b[^"]*"`) const regex = new RegExp(`class\\s*=\\s*"[^"]*\\b${className}\\b[^"]*"`)
@ -32,15 +33,19 @@ export const getBodyBlocks = ({
const isTitle = classNames.includes('title') const isTitle = classNames.includes('title')
const isSubtitle = classNames.includes('subtitle') const isSubtitle = classNames.includes('subtitle')
const isCoverImage = const isCoverImage =
b.order === 4 && b.order === ArticleBlocksOrders.cover &&
b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.ImageBlock b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.ImageBlock
const isAuthor = const isAuthor =
b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock && b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock &&
similarity(b.text, mentions.map((m) => m.name).join('')) > 0.8 similarity(b.text, mentions.map((m) => m.name).join('')) > 0.8
const isSummary = const isSummary =
b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock && b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock &&
summary === b.text summary === b.text
const isTag = const isTag =
b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock && b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock &&
similarity(b.text, tags.map((t) => `#${t}`).join(' ')) > 0.8 similarity(b.text, tags.map((t) => `#${t}`).join(' ')) > 0.8
@ -69,7 +74,7 @@ export const getArticleCover = (
return ( return (
((blocks || []).find( ((blocks || []).find(
(b) => (b) =>
b.order === 4 && b.order === ArticleBlocksOrders.cover &&
b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.ImageBlock, b.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.ImageBlock,
) as UnbodyImageBlock) || null ) as UnbodyImageBlock) || null
) )

View File

@ -2539,6 +2539,11 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
react-blurhash@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/react-blurhash/-/react-blurhash-0.3.0.tgz#f125801d052644f74420c79b05981691d17c9705"
integrity sha512-XlKr4Ns1iYFRnk6DkAblNbAwN/bTJvxTVoxMvmTcURdc5oLoXZwqAF9N3LZUh/HT+QFlq5n6IS6VsDGsviYAiQ==
react-dom@18.2.0, react-dom@^18.2.0: react-dom@18.2.0, react-dom@^18.2.0:
version "18.2.0" version "18.2.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d"