diff --git a/.lintstagedrc b/.lintstagedrc index e8df73eb..f6d24a5e 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,5 @@ { - "*.{js,ts,tsx,json,scss,css,html,astro}": "prettier --write", + "*.{js,ts,tsx,json,scss,css,html}": "prettier --write", "package.json": "sort-package-json", "*.{scss,css}": "stylelint", "*.{ts,tsx,js}": "eslint --fix", diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index b49b6a2e..b5fce7aa 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -11,6 +11,7 @@ import { renderMarkdown } from '@astrojs/markdown-remark' import { markdownOptions } from '../../../mdx.config' import { useStore } from '@nanostores/solid' import { session } from '../../stores/auth' +import { incrementView, loadArticle } from '../../stores/zine/articles' const MAX_COMMENT_LEVEL = 6 @@ -43,14 +44,24 @@ export const FullArticle = (props: ArticleProps) => { const auth = useStore(session) onMount(() => { - const b: string = props.article?.body - if (b?.toString().startsWith('<')) { - setBody(b) - } else { - renderMarkdown(b, markdownOptions).then(({ code }) => setBody(code)) + if (!props.article.body) { + loadArticle({ slug: props.article.slug }) } }) + // onMount(() => { + // const b: string = props.article?.body + // if (b?.toString().startsWith('<')) { + // setBody(b) + // } else { + // renderMarkdown(b, markdownOptions).then(({ code }) => setBody(code)) + // } + // }) + + onMount(() => { + incrementView({ articleSlug: props.article.slug }) + }) + const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt))) const mainTopic = () => diff --git a/src/components/Nav/Header.tsx b/src/components/Nav/Header.tsx index d2851ee2..ea8b1fc5 100644 --- a/src/components/Nav/Header.tsx +++ b/src/components/Nav/Header.tsx @@ -8,7 +8,7 @@ import { t } from '../../utils/intl' import { useModalStore, showModal, useWarningsStore } from '../../stores/ui' import { useStore } from '@nanostores/solid' import { session as ssession } from '../../stores/auth' -import { route, router } from '../../stores/router' +import { handleClientRouteLinkClick, router } from '../../stores/router' import './Header.scss' const resources = [ @@ -42,8 +42,22 @@ export const Header = () => { // derived const authorized = createMemo(() => session()?.user?.slug) - const enterClick = route(() => showModal('auth')) - const bellClick = createMemo(() => (authorized() ? route(toggleWarnings) : enterClick)) + + const handleEnterClick = (ev) => { + showModal('auth') + handleClientRouteLinkClick(ev) + } + + const handleBellIconClick = (ev) => { + if (!authorized()) { + handleEnterClick(ev) + return + } + + toggleWarnings() + handleClientRouteLinkClick(ev) + } + return (
@@ -52,7 +66,7 @@ export const Header = () => {