diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..79ecc5a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.codeActionsOnSave": { + "source.organizeImports": true + } +} diff --git a/src/app/[...slug]/page.tsx b/src/app/[...slug]/page.tsx index 84b5247..fb11ce2 100644 --- a/src/app/[...slug]/page.tsx +++ b/src/app/[...slug]/page.tsx @@ -1,22 +1,22 @@ "use server"; -import { cache } from "react"; -import { headers } from "next/headers"; import { Metadata } from "next"; +import { headers } from "next/headers"; import { permanentRedirect } from "next/navigation"; +import { cache } from "react"; +import { api } from "../../../config"; +import { fetchFromApi } from "../../api/request"; import { - ContentResponse, Content, + ContentResponse, ContentResponseWithFetchResponse } from "../../models/models"; -import { fetchFromApi } from "../../api/request"; import { asInsight } from "../../utils/insight"; -import { Renderer } from "./renderer"; -import { runWithHandleErrorIf, throwIfError } from "../handler"; -import { buildUrl, sluggize } from "../../utils/url"; import { requestContextFrom } from "../../utils/requestContext"; +import { buildUrl, sluggize } from "../../utils/url"; +import { runWithHandleErrorIf, throwIfError } from "../handler"; import { generateForArticleOrPage } from "../metadata"; -import { api } from "../../../config"; +import { Renderer } from "./renderer"; // TODO: move somewhere if possible const cachedFindByPath = cache(async (path: string) => { diff --git a/src/app/[...slug]/renderer.tsx b/src/app/[...slug]/renderer.tsx index 084fa84..26a1a15 100644 --- a/src/app/[...slug]/renderer.tsx +++ b/src/app/[...slug]/renderer.tsx @@ -1,11 +1,11 @@ +import { externalResources as externalResourcesConfig } from "../../../config"; import { ContentComponent, CoverComponent, InjectScriptComponent } from "../../components/components"; -import { Content, Insight, InjectScript } from "../../models/models"; +import { Content, InjectScript, Insight } from "../../models/models"; import { getScripts } from "../../utils/injectScript"; -import { externalResources as externalResourcesConfig } from "../../../config"; export const Renderer: React.FunctionComponent<{ content: Content; diff --git a/src/app/archives/page.tsx b/src/app/archives/page.tsx index b1a2cfe..b3bb344 100644 --- a/src/app/archives/page.tsx +++ b/src/app/archives/page.tsx @@ -6,8 +6,8 @@ import { fetchFromApi } from "../../api/request"; import { Archive, ArchiveResponse } from "../../models/models"; import { requestContextFrom } from "../../utils/requestContext"; import { buildUrl } from "../../utils/url"; -import { Renderer } from "./renderer"; import { runWithHandleErrorIf, throwIfError } from "../handler"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/articles/[...slug]/page.tsx b/src/app/articles/[...slug]/page.tsx index d53f172..d9ec3ea 100644 --- a/src/app/articles/[...slug]/page.tsx +++ b/src/app/articles/[...slug]/page.tsx @@ -1,23 +1,23 @@ "use server"; -import { cache } from "react"; -import { headers } from "next/headers"; import { Metadata } from "next"; +import { headers } from "next/headers"; import { notFound } from "next/navigation"; +import { cache } from "react"; +import { api } from "../../../../config"; +import { fetchFromApi } from "../../../api/request"; import { - ContentResponse, Content, + ContentResponse, ContentResponseWithFetchResponse } from "../../../models/models"; -import { isMatch } from "../../../utils/match"; -import { fetchFromApi } from "../../../api/request"; import { asInsight } from "../../../utils/insight"; -import { Renderer } from "./renderer"; +import { isMatch } from "../../../utils/match"; +import { requestContextFrom } from "../../../utils/requestContext"; +import { buildUrl, sluggize } from "../../../utils/url"; import { runWithHandleErrorIf, throwIfError } from "../../handler"; import { generateForArticleOrPage } from "../../metadata"; -import { buildUrl, sluggize } from "../../../utils/url"; -import { requestContextFrom } from "../../../utils/requestContext"; -import { api } from "../../../../config"; +import { Renderer } from "./renderer"; const PREFIX_URL = "articles"; diff --git a/src/app/articles/[...slug]/renderer.tsx b/src/app/articles/[...slug]/renderer.tsx index 5928184..6687801 100644 --- a/src/app/articles/[...slug]/renderer.tsx +++ b/src/app/articles/[...slug]/renderer.tsx @@ -1,11 +1,11 @@ +import { externalResources as externalResourcesConfig } from "../../../../config"; import { ContentComponent, CoverComponent, InjectScriptComponent } from "../../../components/components"; -import { Content, Insight, InjectScript } from "../../../models/models"; +import { Content, InjectScript, Insight } from "../../../models/models"; import { getScripts } from "../../../utils/injectScript"; -import { externalResources as externalResourcesConfig } from "../../../../config"; export const Renderer: React.FunctionComponent<{ content: Content; diff --git a/src/app/articles/page.tsx b/src/app/articles/page.tsx index 6abba61..7c5c2c4 100644 --- a/src/app/articles/page.tsx +++ b/src/app/articles/page.tsx @@ -1,13 +1,13 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../../config"; import { fetchFromApi } from "../../api/request"; import { Article, ArticleResponseWithCount } from "../../models/models"; import { requestContextFrom } from "../../utils/requestContext"; import { buildQueryParams, buildUrl } from "../../utils/url"; -import { Renderer } from "./renderer"; import { runWithHandleErrorIf, throwIfError } from "../handler"; -import { api } from "../../../config"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/clientLayout.tsx b/src/app/clientLayout.tsx index c054cda..88dc64d 100644 --- a/src/app/clientLayout.tsx +++ b/src/app/clientLayout.tsx @@ -1,14 +1,14 @@ "use client"; -import "../styles/globals.scss"; import React, { useEffect } from "react"; -import { getTheme } from "../services/theme"; +import { copyrights, footerItems, headerItems } from "../../config"; import { BackToTopComponent, FooterComponent, HeaderComponent } from "../components/components"; -import { headerItems, footerItems, copyrights } from "../../config"; +import { getTheme } from "../services/theme"; +import "../styles/globals.scss"; export default function ClientLayout({ children diff --git a/src/app/feeds/index.xml/route.ts b/src/app/feeds/index.xml/route.ts index f726e0a..f1e754a 100644 --- a/src/app/feeds/index.xml/route.ts +++ b/src/app/feeds/index.xml/route.ts @@ -1,8 +1,8 @@ import { headers } from "next/headers"; -import { Feed } from "../../../models/models"; +import { api, mainAuthor, siteName, url } from "../../../../config"; import { fetchFromApi } from "../../../api/request"; +import { Feed } from "../../../models/models"; import { generateFeedsString } from "../../../services/feeds"; -import { api, url, siteName, mainAuthor } from "../../../../config"; import { requestContextFrom } from "../../../utils/requestContext"; import { buildUrl, sluggize } from "../../../utils/url"; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8655427..533b513 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,19 +1,19 @@ -import React from "react"; import { Metadata } from "next"; -import ClientLayout from "./clientLayout"; -import { getTheme } from "../services/theme"; +import React from "react"; import { - siteName, - mainAuthor, - lang, - url, - locale, defaultImage, favicon, - injectMetas + injectMetas, + lang, + locale, + mainAuthor, + siteName, + url } from "../../config"; import { HeadMetaComponent } from "../components/components"; +import { getTheme } from "../services/theme"; import { fullUrl } from "../utils/url"; +import ClientLayout from "./clientLayout"; export const metadata: Metadata = { title: siteName, diff --git a/src/app/metadata.ts b/src/app/metadata.ts index 27e6178..dce81ef 100644 --- a/src/app/metadata.ts +++ b/src/app/metadata.ts @@ -1,11 +1,11 @@ import { Metadata } from "next"; -import { Content } from "../models/content"; import { defaultImage, defaultRobotsMeta, locale, siteName } from "../../config"; +import { Content } from "../models/content"; import { toISODateSrting } from "../utils/time"; import { fullUrl } from "../utils/url"; diff --git a/src/app/page.tsx b/src/app/page.tsx index c45bf5b..f06c541 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,13 +1,13 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../config"; import { fetchFromApi } from "../api/request"; import { Article, ArticleResponseWithCount } from "../models/models"; import { requestContextFrom } from "../utils/requestContext"; import { buildQueryParams, buildUrl } from "../utils/url"; -import { Renderer } from "./renderer"; import { runWithHandleErrorIf, throwIfError } from "./handler"; -import { api } from "../../config"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/renderer.tsx b/src/app/renderer.tsx index a420167..e4602ae 100644 --- a/src/app/renderer.tsx +++ b/src/app/renderer.tsx @@ -1,10 +1,10 @@ -import { Article } from "../models/models"; import { CoverComponent, RecentArticlesComponent } from "../components/components"; -import styles from "../styles/home.module.scss"; +import { Article } from "../models/models"; import containerStyles from "../styles/components/container.module.scss"; +import styles from "../styles/home.module.scss"; export const Renderer: React.FunctionComponent<{ articles: Array
; diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index d3b8e67..c50261e 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -1,12 +1,12 @@ "use server"; import { headers } from "next/headers"; -import { requestContextFrom } from "../../utils/requestContext"; -import { SearchResponse, SearchResponseWithCount } from "../../models/models"; -import { fetchFromApi } from "../../api/request"; -import { Renderer } from "./renderer"; import { api } from "../../../config"; +import { fetchFromApi } from "../../api/request"; +import { SearchResponse, SearchResponseWithCount } from "../../models/models"; +import { requestContextFrom } from "../../utils/requestContext"; import { buildQueryParams, buildUrl, sluggize } from "../../utils/url"; +import { Renderer } from "./renderer"; const emptyResult = { count: 0, diff --git a/src/app/search/renderer.tsx b/src/app/search/renderer.tsx index 12ea74c..cb93c17 100644 --- a/src/app/search/renderer.tsx +++ b/src/app/search/renderer.tsx @@ -1,7 +1,7 @@ "use client"; -import React, { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; +import React, { useEffect, useState } from "react"; import { CoverComponent, SearchResultComponent diff --git a/src/app/series/[slug]/page.tsx b/src/app/series/[slug]/page.tsx index 7429ca8..d68f55b 100644 --- a/src/app/series/[slug]/page.tsx +++ b/src/app/series/[slug]/page.tsx @@ -1,17 +1,17 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../../../config"; import { fetchFromApi } from "../../../api/request"; import { Article, - SeriresWithArticlesResponse, - SeriresWithArticles + SeriresWithArticles, + SeriresWithArticlesResponse } from "../../../models/models"; import { requestContextFrom } from "../../../utils/requestContext"; -import { Renderer } from "./renderer"; -import { runWithHandleErrorIf, throwIfError } from "../../handler"; -import { api } from "../../../../config"; import { buildUrl, sluggize } from "../../../utils/url"; +import { runWithHandleErrorIf, throwIfError } from "../../handler"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/series/page.tsx b/src/app/series/page.tsx index 771e922..3c572be 100644 --- a/src/app/series/page.tsx +++ b/src/app/series/page.tsx @@ -1,13 +1,13 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../../config"; import { fetchFromApi } from "../../api/request"; import { Series, SeriesResponse } from "../../models/models"; import { requestContextFrom } from "../../utils/requestContext"; -import { Renderer } from "./renderer"; -import { runWithHandleErrorIf, throwIfError } from "../handler"; -import { api } from "../../../config"; import { buildUrl, sluggize } from "../../utils/url"; +import { runWithHandleErrorIf, throwIfError } from "../handler"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx index dfd2b00..e6796e3 100644 --- a/src/app/settings/page.tsx +++ b/src/app/settings/page.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useState } from "react"; +import { useState } from "react"; import { CoverComponent, DropdownComponent } from "../../components/components"; import { getTheme } from "../../services/theme"; import containerStyles from "../../styles/components/container.module.scss"; diff --git a/src/app/sitemap.xml/route.ts b/src/app/sitemap.xml/route.ts index 01e51fe..4b4f65b 100644 --- a/src/app/sitemap.xml/route.ts +++ b/src/app/sitemap.xml/route.ts @@ -1,9 +1,9 @@ import { headers } from "next/headers"; -import { Sitemap } from "../../models/models"; +import { api } from "../../../config"; import { fetchFromApi } from "../../api/request"; +import { Sitemap } from "../../models/models"; import { generateSitemapString } from "../../services/sitemap"; import { requestContextFrom } from "../../utils/requestContext"; -import { api } from "../../../config"; import { buildUrl, sluggize } from "../../utils/url"; export async function GET() { diff --git a/src/app/status/page.tsx b/src/app/status/page.tsx index 22a606a..017fc95 100644 --- a/src/app/status/page.tsx +++ b/src/app/status/page.tsx @@ -1,11 +1,11 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../../config"; import { fetchFromApi } from "../../api/request"; import { requestContextFrom } from "../../utils/requestContext"; -import { Renderer } from "./renderer"; -import { api } from "../../../config"; import { buildUrl, sluggize } from "../../utils/url"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { const { props } = await handler(req); diff --git a/src/app/tags/[...slug]/page.tsx b/src/app/tags/[...slug]/page.tsx index bc0f201..f3c5096 100644 --- a/src/app/tags/[...slug]/page.tsx +++ b/src/app/tags/[...slug]/page.tsx @@ -1,13 +1,13 @@ "use server"; import { headers } from "next/headers"; +import { api } from "../../../../config"; import { fetchFromApi } from "../../../api/request"; import { Article, ArticleResponseWithCount } from "../../../models/models"; import { requestContextFrom } from "../../../utils/requestContext"; -import { Renderer } from "./renderer"; -import { runWithHandleErrorIf, throwIfError } from "../../handler"; -import { api } from "../../../../config"; import { buildQueryParams, buildUrl, sluggize } from "../../../utils/url"; +import { runWithHandleErrorIf, throwIfError } from "../../handler"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/tags/page.tsx b/src/app/tags/page.tsx index 0588dc0..d401808 100644 --- a/src/app/tags/page.tsx +++ b/src/app/tags/page.tsx @@ -1,13 +1,13 @@ "use server"; import { headers } from "next/headers"; -import { Tag } from "../../models/models"; +import { api } from "../../../config"; import { fetchFromApi } from "../../api/request"; +import { Tag } from "../../models/models"; import { requestContextFrom } from "../../utils/requestContext"; -import { Renderer } from "./renderer"; -import { runWithHandleErrorIf, throwIfError } from "../handler"; -import { api } from "../../../config"; import { buildUrl, sluggize } from "../../utils/url"; +import { runWithHandleErrorIf, throwIfError } from "../handler"; +import { Renderer } from "./renderer"; export default async function Page(req: any) { return runWithHandleErrorIf(await run(req)); diff --git a/src/app/tags/renderer.tsx b/src/app/tags/renderer.tsx index 6b811ea..074c68b 100644 --- a/src/app/tags/renderer.tsx +++ b/src/app/tags/renderer.tsx @@ -1,7 +1,7 @@ "use client"; -import { Tag } from "../../models/models"; import { CoverComponent, TagsComponent } from "../../components/components"; +import { Tag } from "../../models/models"; export const Renderer: React.FunctionComponent<{ tags: Array; diff --git a/src/components/archives.tsx b/src/components/archives.tsx index 98c8187..ccf61cc 100644 --- a/src/components/archives.tsx +++ b/src/components/archives.tsx @@ -1,13 +1,13 @@ "use client"; -import React, { useState, useEffect } from "react"; +import React, { useEffect, useState } from "react"; +import { archivesPage } from "../../config"; import { Archive, ArchiveFormatedDate } from "../models/models"; -import { splittedBy } from "../utils/time"; import styles from "../styles/archives.module.scss"; import containerStyles from "../styles/components/container.module.scss"; -import { archivesPage } from "../../config"; -import { DropdownComponent } from "./components"; import { sequentialPadPosNum } from "../utils/nums"; +import { splittedBy } from "../utils/time"; +import { DropdownComponent } from "./components"; export const ArchivesComponent: React.FunctionComponent<{ archives: Array; diff --git a/src/components/articles.tsx b/src/components/articles.tsx index 08642a8..3f34d50 100644 --- a/src/components/articles.tsx +++ b/src/components/articles.tsx @@ -2,10 +2,10 @@ import Link from "next/link"; import { Article } from "../models/models"; import styles from "../styles/articles.module.scss"; import articlesInSection from "../styles/articlesInSection.module.scss"; -import homeStyles from "../styles/home.module.scss"; -import flexStyles from "../styles/components/flex.module.scss"; -import containerStyles from "../styles/components/container.module.scss"; import buttonStyles from "../styles/components/button.module.scss"; +import containerStyles from "../styles/components/container.module.scss"; +import flexStyles from "../styles/components/flex.module.scss"; +import homeStyles from "../styles/home.module.scss"; import { splittedBy } from "../utils/time"; export const ArticlesComponent: React.FunctionComponent<{ diff --git a/src/components/content.tsx b/src/components/content.tsx index afcf094..65ca0c6 100644 --- a/src/components/content.tsx +++ b/src/components/content.tsx @@ -1,14 +1,14 @@ "use client"; import { useState } from "react"; -import { Content, ContentMeta, Insight, BackendMeta } from "../models/models"; +import { publicApi } from "../../config"; +import { fetchFromApi } from "../api/request"; +import { BackendMeta, Content, ContentMeta, Insight } from "../models/models"; import containerStyles from "../styles/components/container.module.scss"; import contentStyles from "../styles/components/content.module.scss"; -import { Accordion } from "./accordion"; -import { fetchFromApi } from "../api/request"; import { mergeBackendMeta } from "../utils/insight"; -import { publicApi } from "../../config"; import { buildUrl, sluggize } from "../utils/url"; +import { Accordion } from "./accordion"; export const ContentComponent: React.FunctionComponent<{ content: Content; diff --git a/src/components/cover.tsx b/src/components/cover.tsx index 144f9c5..edd7874 100644 --- a/src/components/cover.tsx +++ b/src/components/cover.tsx @@ -1,10 +1,10 @@ import Link from "next/link"; -import { TagComponent } from "./tag"; -import { NavigationComponent } from "./navigation"; +import { coverBottomItems, subTitle, title } from "../../config"; import { Tag } from "../models/models"; import styles from "../styles/components/cover.module.scss"; import { toDate } from "../utils/time"; -import { title, subTitle, coverBottomItems } from "../../config"; +import { NavigationComponent } from "./navigation"; +import { TagComponent } from "./tag"; type Props = { title: string; diff --git a/src/components/footer.tsx b/src/components/footer.tsx index dbdd1e8..9ed95ee 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -1,6 +1,6 @@ import Link from "next/link"; -import styles from "../styles/footer.module.scss"; import containerStyles from "../styles/components/container.module.scss"; +import styles from "../styles/footer.module.scss"; export const FooterComponent: React.FunctionComponent<{ copyrights: string; diff --git a/src/components/header.tsx b/src/components/header.tsx index ff885b1..5f5fd28 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -1,5 +1,5 @@ -import { NavigationComponent } from "./navigation"; import styles from "../styles/navigation.module.scss"; +import { NavigationComponent } from "./navigation"; export const HeaderComponent: React.FunctionComponent<{ items: Array; diff --git a/src/components/pagination.tsx b/src/components/pagination.tsx index 5efd92b..a3731c6 100644 --- a/src/components/pagination.tsx +++ b/src/components/pagination.tsx @@ -1,10 +1,10 @@ // TODO: refactor all +import Link from "next/link"; import { PaginationNumbers } from "../models/models"; import { calcNumberOfPages, getNumbersForDisplay } from "../services/pagination"; -import Link from "next/link"; import style from "../styles/components/pagination.module.scss"; // TODO: set default number of articles in one page from config. diff --git a/src/components/searchResult.tsx b/src/components/searchResult.tsx index 4ac2f01..4ed7c22 100644 --- a/src/components/searchResult.tsx +++ b/src/components/searchResult.tsx @@ -1,8 +1,8 @@ -import React from "react"; import Link from "next/link"; +import React from "react"; +import { SearchResponse } from "../models/models"; import styles from "../styles/search.module.scss"; import { splittedBy } from "../utils/time"; -import { SearchResponse } from "../models/models"; export const SearchResultComponent: React.FunctionComponent<{ hits: number; diff --git a/src/components/series.tsx b/src/components/series.tsx index 9d7534e..3296ac3 100644 --- a/src/components/series.tsx +++ b/src/components/series.tsx @@ -1,7 +1,7 @@ import Link from "next/link"; import { Article, Series, SeriresWithArticles } from "../models/models"; -import styles from "../styles/series.module.scss"; import containerStyles from "../styles/components/container.module.scss"; +import styles from "../styles/series.module.scss"; export const SeriesComponent: React.FunctionComponent<{ series: Array; diff --git a/src/components/tags.tsx b/src/components/tags.tsx index c804e6e..086ca66 100644 --- a/src/components/tags.tsx +++ b/src/components/tags.tsx @@ -1,11 +1,11 @@ "use client"; -import React, { useState, useEffect } from "react"; -import { TagComponent } from "./tag"; +import React, { useEffect, useState } from "react"; +import { tagsPage } from "../../config"; import { Tag } from "../models/models"; import containerStyles from "../styles/components/container.module.scss"; import style from "../styles/tags.module.scss"; -import { tagsPage } from "../../config"; +import { TagComponent } from "./tag"; export const TagsComponent: React.FunctionComponent<{ tags: Array }> = ({ tags diff --git a/src/utils/injectScript.ts b/src/utils/injectScript.ts index 91b12b5..02f356c 100644 --- a/src/utils/injectScript.ts +++ b/src/utils/injectScript.ts @@ -1,5 +1,5 @@ -import { InjectScript } from "../models/script"; import { ExternalResources } from "../models/externalResource"; +import { InjectScript } from "../models/script"; // TODO: write test code export function getScripts(