diff --git a/gatsby-node.ts b/gatsby-node.ts index 50b0e3a0..b3ada59d 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -48,6 +48,7 @@ export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] type Articles implements Node @dontInfer { slug: String, title: String, + tldr: String, body: String, published_at: String, updated_at: String, @@ -120,6 +121,7 @@ async function registerArticle( id: article.slug, slug: article.slug, title: article.title, + tldr: article.tldr, body: article.body, tags: article.tags, published_at: article.publishedAt, @@ -254,6 +256,7 @@ export const createPages: GatsbyNode['createPages'] = async ({graphql, actions}) nodes { slug title + tldr tags { slug name diff --git a/graphql/documents.graphql b/graphql/documents.graphql index ddd18bfb..22f592ce 100644 --- a/graphql/documents.graphql +++ b/graphql/documents.graphql @@ -8,6 +8,7 @@ query all { allPublicArticles { slug title + tldr publishedAt updatedAt tags { diff --git a/graphql/schema.graphql b/graphql/schema.graphql index d879767b..8935efdf 100644 --- a/graphql/schema.graphql +++ b/graphql/schema.graphql @@ -1,24 +1,13 @@ -type Sitedata { - profile: String! - shortProfile: String! -} - -type Tag { - slug: String! - name: String! -} - -type Mutation { - newTag(slug: String!, title: String!): String! - newArticle(slug: String!, title: String!): String! - updateArticle(slug: String!, title: String!, tags: [String!]!, isFavorite: Boolean!, body: String!): String! - publishArticle(slug: String!): String! +schema { + query: Query + mutation: Mutation } type Article { slug: String! body: String! title: String! + tldr: String! tags: [Tag!]! isFavorite: Boolean! publishedAt: String! @@ -26,6 +15,13 @@ type Article { isPublished: Boolean! } +type Mutation { + newTag(slug: String!, title: String!): String! + newArticle(slug: String!, title: String!): String! + updateArticle(slug: String!, title: String!, tldr: String!, tags: [String!]!, isFavorite: Boolean!, body: String!): String! + publishArticle(slug: String!): String! +} + type Query { allPublicArticles: [Article!]! allArticles: [Article!]! @@ -34,7 +30,12 @@ type Query { sitedata: Sitedata! } -schema { - query: Query - mutation: Mutation +type Sitedata { + profile: String! + shortProfile: String! +} + +type Tag { + slug: String! + name: String! } diff --git a/package.json b/package.json index f1739dd5..764d2783 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "remark-gfm": "^4.0.0", "remark-slug": "^7.0.1", "remark-toc": "^9.0.0", - "remove-markdown": "^0.5.0", "toml": "^3.0.0", "typescript": "^5.4.5", "unist-util-visit": "^5.0.0" diff --git a/src/components/feature/Article/InnerEmbedCard/InnerEmbedCard.tsx b/src/components/feature/Article/InnerEmbedCard/InnerEmbedCard.tsx index 3905fa01..bb9e81e2 100644 --- a/src/components/feature/Article/InnerEmbedCard/InnerEmbedCard.tsx +++ b/src/components/feature/Article/InnerEmbedCard/InnerEmbedCard.tsx @@ -7,7 +7,6 @@ import * as style from './InnerEmbedCard.css'; import {Link, graphql, useStaticQuery} from 'gatsby'; import React from 'react'; -import RemoveMD from 'remove-markdown'; import Article from '@mytypes/Article'; interface Props { @@ -27,6 +26,7 @@ export const InnerEmbedCard = (props: Props): React.ReactElement => { nodes { slug title + tldr body tags { slug @@ -49,9 +49,7 @@ export const InnerEmbedCard = (props: Props): React.ReactElement => { {data.title} {`watasuke.net - ${props.slug}`} - - {RemoveMD(data.body.slice(0, 120) + (data.body.length > 140 ? ' ...' : ''))} - + {data.tldr} ); }; diff --git a/src/components/feature/ArticleList/ArticleCard/ArticleCard.tsx b/src/components/feature/ArticleList/ArticleCard/ArticleCard.tsx index e454708f..a2a9c725 100644 --- a/src/components/feature/ArticleList/ArticleCard/ArticleCard.tsx +++ b/src/components/feature/ArticleList/ArticleCard/ArticleCard.tsx @@ -7,7 +7,6 @@ import * as style from './ArticleCard.css'; import {Link} from 'gatsby'; import React from 'react'; -import RemoveMD from 'remove-markdown'; import {TagContainer} from '@/feature/Tag'; import Article from '@mytypes/Article'; @@ -31,12 +30,7 @@ export const ArticleCard = ({article}: Props): React.ReactElement => {

{article.title}

-

- { - // 140字に制限して内容を表示、超過分は...で - RemoveMD(article.body.slice(0, 140) + (article.body.length > 140 ? ' ...' : '')) - } -

+

{article.tldr}

); diff --git a/src/pages/blog.tsx b/src/pages/blog.tsx index ab433365..8df770a9 100644 --- a/src/pages/blog.tsx +++ b/src/pages/blog.tsx @@ -54,6 +54,7 @@ export const query = graphql` nodes { slug title + tldr body tags { slug diff --git a/src/pages/blog/article.tsx b/src/pages/blog/article.tsx index 32e99de6..a441b319 100644 --- a/src/pages/blog/article.tsx +++ b/src/pages/blog/article.tsx @@ -46,6 +46,7 @@ export const query = graphql` nodes { slug title + tldr body tags { slug diff --git a/src/template/Article.tsx b/src/template/Article.tsx index 34c63879..b958be68 100644 --- a/src/template/Article.tsx +++ b/src/template/Article.tsx @@ -8,7 +8,6 @@ import '@/common/main.css'; import * as style from '@/feature/Article/Article.css'; import {Seo, Layout, Breadcrumb} from '@/common'; import React from 'react'; -import RemoveMD from 'remove-markdown'; import {BlogContent, ProfileCard, TocRight} from '@/feature/Article'; import {AllTagList} from '@/feature/Tag'; import {GenBreadcrumb} from '@utils/Breadcrumb'; @@ -53,7 +52,7 @@ export default function Articale(prop: Props): React.ReactElement { export const Head = ({pageContext}: Props): React.ReactElement => ( diff --git a/src/template/Tag.tsx b/src/template/Tag.tsx index 57a5d095..1a97a600 100644 --- a/src/template/Tag.tsx +++ b/src/template/Tag.tsx @@ -46,6 +46,7 @@ export const query = graphql` nodes { slug title + tldr body tags { name diff --git a/src/types/Article.d.ts b/src/types/Article.d.ts index 84fe304c..6d6ab84b 100644 --- a/src/types/Article.d.ts +++ b/src/types/Article.d.ts @@ -7,6 +7,7 @@ export default interface Article { slug: string; title: string; + tldr: string; body: string; tags: { slug: string; diff --git a/src/types/gatsby-types.d.ts b/src/types/gatsby-types.d.ts index 917005a0..4657cad0 100644 --- a/src/types/gatsby-types.d.ts +++ b/src/types/gatsby-types.d.ts @@ -46,6 +46,7 @@ type Articles = Node & { readonly slug: Maybe; readonly tags: Maybe>>; readonly title: Maybe; + readonly tldr: Maybe; readonly updated_at: Maybe; }; @@ -104,6 +105,7 @@ type ArticlesFieldSelector = { readonly slug: InputMaybe; readonly tags: InputMaybe; readonly title: InputMaybe; + readonly tldr: InputMaybe; readonly updated_at: InputMaybe; }; @@ -117,6 +119,7 @@ type ArticlesFilterInput = { readonly slug: InputMaybe; readonly tags: InputMaybe; readonly title: InputMaybe; + readonly tldr: InputMaybe; readonly updated_at: InputMaybe; }; @@ -171,6 +174,7 @@ type ArticlesSortInput = { readonly slug: InputMaybe; readonly tags: InputMaybe; readonly title: InputMaybe; + readonly tldr: InputMaybe; readonly updated_at: InputMaybe; }; @@ -1849,6 +1853,7 @@ type Query_articlesArgs = { slug: InputMaybe; tags: InputMaybe; title: InputMaybe; + tldr: InputMaybe; updated_at: InputMaybe; }; @@ -3478,7 +3483,7 @@ type GatsbyImageSharpFluidLimitPresentationSizeFragment = { readonly maxHeight: type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>; -type Unnamed_1_Query = { readonly allArticles: { readonly nodes: ReadonlyArray<{ readonly slug: string | null, readonly title: string | null, readonly published_at: string | null, readonly updated_at: string | null, readonly body: string | null, readonly tags: ReadonlyArray<{ readonly slug: string | null, readonly name: string | null } | null> | null }> } }; +type Unnamed_1_Query = { readonly allArticles: { readonly nodes: ReadonlyArray<{ readonly slug: string | null, readonly title: string | null, readonly tldr: string | null, readonly published_at: string | null, readonly updated_at: string | null, readonly body: string | null, readonly tags: ReadonlyArray<{ readonly slug: string | null, readonly name: string | null } | null> | null }> } }; type Unnamed_2_QueryVariables = Exact<{ [key: string]: never; }>; diff --git a/src/utils/graphql.ts b/src/utils/graphql.ts index 67da519c..4cc5801a 100644 --- a/src/utils/graphql.ts +++ b/src/utils/graphql.ts @@ -26,6 +26,7 @@ export type Article = { slug: Scalars['String']['output']; tags: Array; title: Scalars['String']['output']; + tldr: Scalars['String']['output']; updatedAt: Scalars['String']['output']; }; @@ -61,6 +62,7 @@ export type MutationUpdateArticleArgs = { slug: Scalars['String']['input']; tags: Array; title: Scalars['String']['input']; + tldr: Scalars['String']['input']; }; export type Query = { @@ -92,7 +94,7 @@ export type Tag = { export type AllQueryVariables = Exact<{ [key: string]: never; }>; -export type AllQuery = { __typename?: 'Query', allPublicArticles: Array<{ __typename?: 'Article', slug: string, title: string, publishedAt: string, updatedAt: string, body: string, tags: Array<{ __typename?: 'Tag', slug: string, name: string }> }>, allTags: Array<{ __typename?: 'Tag', slug: string, name: string }>, sitedata: { __typename?: 'Sitedata', profile: string, shortProfile: string } }; +export type AllQuery = { __typename?: 'Query', allPublicArticles: Array<{ __typename?: 'Article', slug: string, title: string, tldr: string, publishedAt: string, updatedAt: string, body: string, tags: Array<{ __typename?: 'Tag', slug: string, name: string }> }>, allTags: Array<{ __typename?: 'Tag', slug: string, name: string }>, sitedata: { __typename?: 'Sitedata', profile: string, shortProfile: string } }; export const AllDocument = gql` @@ -100,6 +102,7 @@ export const AllDocument = gql` allPublicArticles { slug title + tldr publishedAt updatedAt tags {