Giter Club home page Giter Club logo

almond-blog's Introduction

icon almond-blog

logo

個人的な技術ブログのソースコードです。

Languages and Tools:

nextjs typescript

🚀 特徴

Next.js + TypeScript製

Next.jsとTypeScriptにより実装されています。

Next.jsは、Reactベースのフレームワークで、サーバーサイドレンダリング(SSR)や静的サイト生成(SSG)をサポートしています。 これによりパフォーマンスやSEO向上を図ることができます。

また、言語にはよりモダンなTypeScriptを採用しています。これは自身の学習のためです。サイトの性能には影響しません。

SSGによる記事ページ生成

SSG(Static Site Generation)により静的な記事ページを生成しています。

SSGはサイトのビルド時にあらかじめHTMLファイルを生成し、これらを静的ファイルとして配信する方法です。これにより高速で安定したページリロードを可能にします。

Markdownパーサー

Markdownパーサーにより、Markdownで書かれた記事をHTMLに変換しています。 Markdownパーサーの実装は以下のように行われています。

export const markdownToHtml = async (markdownContent: string): Promise<string> => {
  const result = unified()
  .use(remarkParse) // Parse markdown.
  .use(remarkGfm) // Support GFM (tables, autolinks, tasklists, strikethrough).
  .use(remarkRehype) // Turn it into HTML.
  .use(rehypeSlug)
  .use(rehypeCodeTitles) // add code block titles
  .use(rehypePrism) // syntax hightlighting
  .use(rehypeStringify) // Serialize HTML.
  .processSync(markdownContent)
  .toString();
  return result;
};

以下に例を示します。

image

image

自動追尾目次

tocbot を用いて自動追尾目次(上図参照)を実装しています。

Syntax Highglighting

上記のMarddownパーサーでは、HTMLに変換した後にHTML解析を行ってPrism.jsによるシンタックスハイライティングを行っています。

Prism.jsだけで対応できない行ハイライトやdiffのデザインは独自に実装しています。

image

image

image

SSRによるサイトマップ生成

SSR(Server Side Rendering)によりリアルタイムで動的なサイトマップ生成を行います。 サイトマップは https://almond-latte.com/sitemap.xml から取得できます。

タグ機能

ブログ記事のタイトル下にあるタグをクリックすることで同じタグがついた記事を検索できます。

image

almond-blog's People

Contributors

almond-latte avatar

Watchers

 avatar

almond-blog's Issues

npmとyarnが混在している

まず、本当にyarnが必要なのか?

  • 高速インストール
  • ロックファイル
  • ワークスペース

等がyarnのメリットだろうが、npmのバージョンアップによりほとんど大差なくなっているらしい。
今後の方針としては、yarnからnpmに移行することにする。理由は大きく以下の二つ

  • yarnのメリットが薄い
  • npmの方が情報が多い

postsを修正する

  • アイキャッチを削除(スクラップ記事はアイキャッチ不要)
  • アバター,オーサー機能を削除(僕しか投稿しない)
  • 文字サイズの調整

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.