From d935483507f182552118936ad369358cf3976c23 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 1 Aug 2022 01:30:50 +0300 Subject: [PATCH] feat: added dynamin article page --- astro.config.mjs | 1 - public/assets/js/load-code-highlight.js | 2 +- src/components/ArticleItem/ArticleItem.tsx | 2 +- src/components/ArticlePost/ArticlePost.astro | 7 +- src/components/BaseHead.astro | 19 +++-- src/components/Counter/Counter.tsx | 17 +++++ src/components/Counter/index.ts | 1 + src/layouts/article.astro | 4 +- src/pages/[...slug].astro | 22 ++++++ src/pages/[article].astro | 80 -------------------- src/pages/articles.astro | 28 ++++--- src/types/main.d.ts | 1 + src/utils/articles.ts | 1 + 13 files changed, 74 insertions(+), 111 deletions(-) create mode 100644 src/components/Counter/Counter.tsx create mode 100644 src/components/Counter/index.ts create mode 100644 src/pages/[...slug].astro delete mode 100644 src/pages/[article].astro diff --git a/astro.config.mjs b/astro.config.mjs index 505fe63..e8cb5fb 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,5 +1,4 @@ import { defineConfig } from 'astro/config'; - import solid from '@astrojs/solid-js'; // https://astro.build/config diff --git a/public/assets/js/load-code-highlight.js b/public/assets/js/load-code-highlight.js index 1d69c9d..57a9fcb 100644 --- a/public/assets/js/load-code-highlight.js +++ b/public/assets/js/load-code-highlight.js @@ -6,7 +6,7 @@ if (window.theme) { /* the {theme} in the path will be dynamically changed */ - const PATH = `assets/css/code-highlight-{theme}.min.css`; + const PATH = `/assets/css/code-highlight-{theme}.min.css`; const $head = document.getElementsByTagName('head')[0]; const getPath = (theme) => PATH.replace(`{theme}`, theme); const createLink = (theme, media) => { diff --git a/src/components/ArticleItem/ArticleItem.tsx b/src/components/ArticleItem/ArticleItem.tsx index 7dd8672..93b046c 100644 --- a/src/components/ArticleItem/ArticleItem.tsx +++ b/src/components/ArticleItem/ArticleItem.tsx @@ -9,7 +9,7 @@ export type ArticleItemProps = { export const ArticleItem: Component = (props) => { return (
- +

{props.data.title}

diff --git a/src/components/ArticlePost/ArticlePost.astro b/src/components/ArticlePost/ArticlePost.astro index 9afa411..788f978 100644 --- a/src/components/ArticlePost/ArticlePost.astro +++ b/src/components/ArticlePost/ArticlePost.astro @@ -16,7 +16,7 @@ const { title, tags, author, published_at } = data;