Skip to content

Commit

Permalink
refactor(page): delete unnecessary convert processes
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Dec 24, 2024
1 parent bc6baba commit 14fc754
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 44 deletions.
11 changes: 1 addition & 10 deletions src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { permanentRedirect } from "next/navigation";
import { cache } from "react";
import { fetchContent } from "../../api";
import {
Content,
ContentResponse,
ContentResponseWithFetchResponse
} from "../../models/models";
Expand Down Expand Up @@ -59,18 +58,10 @@ async function handler(req: any) {

const response: ContentResponseWithFetchResponse =
await cachedFindByPath(path);
const content: Content = {
title: response.body.title,
robotsAttributes: response.body.robotsAttributes,
externalResources: response.body.externalResources,
content: response.body.content,
length: response.body.length,
publishedAt: response.body.publishedAt
} as Content;

return {
props: {
content: content,
content: response.body,
insight: asInsight(response.res)
}
};
Expand Down
6 changes: 1 addition & 5 deletions src/app/archives/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ async function handler(req: any) {
const response: Response = await fetchArchives(await headers());
const archiveResponse = await parseOrThrow<Array<ArchiveResponse>>(response);
const archives: Array<Archive> = archiveResponse.map((article) => {
return {
path: article.path,
title: article.title,
publishedAt: article.publishedAt
} as Archive;
return article;
});

return {
Expand Down
12 changes: 3 additions & 9 deletions src/app/feeds/index.xml/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { headers } from "next/headers";
import { mainAuthor, siteName, url } from "../../../../config";
import { fetchFeeds } from "../../../api";
import { Feed } from "../../../models/models";
import { generateFeedsString } from "../../../services/feeds";
import { fetchFeeds } from "../../../api";

//export async function get(ctx: any) {
export async function GET() {
Expand All @@ -23,14 +23,8 @@ export async function GET() {

let feedResponses = (await response.json()) as Array<Feed>;
const feeds = feedResponses.map((feed) => {
return {
title: feed.title,
link: feed.link,
id: feed.id,
published: feed.published,
updated: feed.updated
};
}) as Array<Feed>;
return feed;
});

const feedXmlString = await generateFeedsString(
url,
Expand Down
8 changes: 1 addition & 7 deletions src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { headers } from "next/headers";
import { fetchSearch } from "../../api";
import {
SearchResponse,
SearchResponseWithCount,
SearchSuccessResult
} from "../../models/models";
Expand Down Expand Up @@ -92,12 +91,7 @@ async function execute(
let contents = [];
contents = (searchResponseWithCount as SearchResponseWithCount).contents.map(
(content) => {
return {
path: content.path,
title: content.title,
content: content.content,
publishedAt: content.publishedAt
} as SearchResponse;
return content;
}
);

Expand Down
7 changes: 1 addition & 6 deletions src/app/series/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ async function handler(req: any) {
const response: Response = await fetchAllSeries(await headers());
const seriesResponse = await parseOrThrow<Array<SeriesResponse>>(response);
const series: Array<Series> = seriesResponse.map((series) => {
return {
id: series.id,
name: series.name,
title: series.title,
description: series.description
} as Series;
return series;
});

return {
Expand Down
8 changes: 1 addition & 7 deletions src/app/tags/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ async function handler(req: any) {
await parseOrThrow<ArticleResponseWithCount>(response);
const articles: Array<Article> = articlesResponseWithCount.articles.map(
(article) => {
return {
path: article.path,
title: article.title,
content: `${article.content} ...`,
publishedAt: article.publishedAt,
updatedAt: article.updatedAt
} as Article;
return article;
}
);

Expand Down

0 comments on commit 14fc754

Please sign in to comment.