Skip to content

Commit

Permalink
refactor(cover): delete unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jan 30, 2024
1 parent 92c0119 commit 291394e
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 88 deletions.
4 changes: 2 additions & 2 deletions src/app/[...slug]/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import {
ContentComponent,
CoverWithNavigationComponent,
CoverComponent,
InjectScriptComponent
} from '../../components/components';
import {
Expand All @@ -23,7 +23,7 @@ export const Renderer: React.FunctionComponent<{
}
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: content.title,
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/archives/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ArchivesComponent, CoverWithNavigationComponent } from '../../components/components';
import { ArchivesComponent, CoverComponent } from '../../components/components';
import { Archive } from '../../models/models';

export const Renderer: React.FunctionComponent<{
archives: Array<Archive>
}> = ({ archives }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: "Archives",
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/articles/[...slug]/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ContentComponent,
CoverWithNavigationComponent,
CoverComponent,
InjectScriptComponent
} from '../../../components/components';
import {
Expand All @@ -23,7 +23,7 @@ export const Renderer: React.FunctionComponent<{
}
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: content.title,
tags: content.tags,
Expand Down
4 changes: 2 additions & 2 deletions src/app/articles/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ArticlesComponent,
CoverWithNavigationComponent,
CoverComponent,
PaginationComponent
} from '../../components/components';

Expand All @@ -11,7 +11,7 @@ export const Renderer: React.FunctionComponent<{
}> = ({ count, currentPage, articles }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={null}
/>
<main>
Expand Down
4 changes: 2 additions & 2 deletions src/app/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Article } from '../models/models';
import { CoverWithNavigationComponent, RecentArticlesComponent } from '../components/components';
import { CoverComponent, RecentArticlesComponent } from '../components/components';
import styles from '../styles/home.module.scss';
import containerStyles from '../styles/components/container.module.scss';

Expand All @@ -9,7 +9,7 @@ export const Renderer: React.FunctionComponent<{

return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={null}
/>
<main>
Expand Down
4 changes: 2 additions & 2 deletions src/app/search/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import {
CoverWithNavigationComponent,
CoverComponent,
SearchResultComponent
} from '../../components/components';
import { SearchResponse, SearchResponseWithCount } from '../../models/models';
Expand Down Expand Up @@ -39,7 +39,7 @@ export const Renderer: React.FunctionComponent<{

return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: "Search (β)",
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/series/[slug]/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CoverWithNavigationComponent, SeriesWithArticlesComponent } from '../../../components/components';
import { CoverComponent, SeriesWithArticlesComponent } from '../../../components/components';

export const Renderer: React.FunctionComponent<{
seriresWithArticles
}> = ({ seriresWithArticles }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: seriresWithArticles.title,
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/series/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CoverWithNavigationComponent, SeriesComponent } from '../../components/components';
import { CoverComponent, SeriesComponent } from '../../components/components';
import { Series } from '../../models/models';

export const Renderer: React.FunctionComponent<{
series: Array<Series>
}> = ({ series }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: "Series",
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, { useState } from 'react';
import { CoverWithNavigationComponent, DropdownComponent } from '../../components/components';
import { CoverComponent, DropdownComponent } from '../../components/components';
import { getTheme } from '../../services/theme';
import containerStyles from '../../styles/components/container.module.scss';

Expand All @@ -19,7 +19,7 @@ export default function Page(){

return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: "Settings",
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/tags/[...slug]/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ArticlesComponent,
CoverWithNavigationComponent,
CoverComponent,
PaginationComponent
} from '../../../components/components';

Expand All @@ -12,7 +12,7 @@ export const Renderer: React.FunctionComponent<{
}> = ({ tagName, currentPage, count, articles }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: tagName,
tags: null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/tags/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use client';

import { Tag } from '../../models/models';
import { CoverWithNavigationComponent, TagsComponent } from '../../components/components';
import { CoverComponent, TagsComponent } from '../../components/components';

export const Renderer: React.FunctionComponent<{
tags: Array<Tag>
}> = ({ tags }) => {
return (
<>
<CoverWithNavigationComponent
<CoverComponent
contentCover={{
title: "Tags",
tags: null,
Expand Down
124 changes: 58 additions & 66 deletions src/components/cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,69 @@ import { title, subTitle, coverBottomItems } from '../../config';

export const CoverComponent: React.FunctionComponent<{ contentCover: ContentCover | null }> = ({ contentCover }) => {
return (
<div className={styles['cover']}>
<div className={`${styles['content-header']}`}>
{
(() => {
if (contentCover) {
return(
<>
<h1 className={`${styles['content-title']}`}>
{contentCover.title}
</h1>
{
(() => {
if (contentCover.publishedAt) {
return(
<span className={`${styles['content-meta']}`}>
{ toDate(contentCover.publishedAt).toUTCString() }
</span>
)
}
})()
}
{
(() => {
if (contentCover.tags) {
return(
<section className={`${styles['tags']}`}>
{contentCover.tags.map((tag: Tag) => {
return(
<TagComponent
tag={tag}
className={null}
key={tag.id}
/>
)
})}
</section>
)
}
})()
}
</>
)
} else {
return <>
<div className={`${styles['site-title']}`}>
<Link href="/" prefetch={false} dangerouslySetInnerHTML={{ __html: title }}>
</Link>
</div>
<span className={`${styles['site-meta']}`}
dangerouslySetInnerHTML={{ __html: subTitle }}>
</span>
</>;
}
})()
}
</div>
</div>
);
}

export const CoverWithNavigationComponent: React.FunctionComponent<{ contentCover: ContentCover | null }> = ({ contentCover }) => {
return(
<>
<CoverComponent
contentCover={contentCover}
/>
<div className={styles['cover']}>
<div className={`${styles['content-header']}`}>
{
(() => {
if (contentCover) {
return(
<>
<h1 className={`${styles['content-title']}`}>
{contentCover.title}
</h1>
{
(() => {
if (contentCover.publishedAt) {
return(
<span className={`${styles['content-meta']}`}>
{ toDate(contentCover.publishedAt).toUTCString() }
</span>
)
}
})()
}
{
(() => {
if (contentCover.tags) {
return(
<section className={`${styles['tags']}`}>
{contentCover.tags.map((tag: Tag) => {
return(
<TagComponent
tag={tag}
className={null}
key={tag.id}
/>
)
})}
</section>
)
}
})()
}
</>
)
} else {
return <>
<div className={`${styles['site-title']}`}>
<Link href="/" prefetch={false} dangerouslySetInnerHTML={{ __html: title }}>
</Link>
</div>
<span className={`${styles['site-meta']}`}
dangerouslySetInnerHTML={{ __html: subTitle }}>
</span>
</>;
}
})()
}
</div>
</div>
<div className={styles['cover-bottom-nav']}>
<NavigationComponent
items={coverBottomItems}
/>
</div>
</>
)
);
}

0 comments on commit 291394e

Please sign in to comment.