diff --git a/.gitignore b/.gitignore index 4950a94..41ca299 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ dist node_modules package-lock.json -public/patterns +public/assets/patterns tslint.log \ No newline at end of file diff --git a/bin/generateScreenshots.ts b/bin/generateScreenshots.ts index c34a003..c5410d9 100644 --- a/bin/generateScreenshots.ts +++ b/bin/generateScreenshots.ts @@ -19,7 +19,7 @@ process.setMaxListeners(0); await page.waitForSelector('.demo'); const element = await page.$('.demo'); await element.screenshot({ - path: `public/patterns/${pattern}.png` + path: `public/assets/patterns/${pattern}.png` }); await page.close(); }) diff --git a/client/hooks/useDocumentTitle.ts b/client/hooks/useDocumentTitle.ts deleted file mode 100644 index aa373d6..0000000 --- a/client/hooks/useDocumentTitle.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * A collection of popular layouts and patterns made with CSS (https://csslayout.io) - * (c) 2019 - 2021 Nguyen Huu Phuoc - */ - -import * as React from 'react'; - -const useDocumentTitle = (title: string) => { - React.useEffect(() => { - document.title = title; - }, [title]); -}; - -export default useDocumentTitle; diff --git a/client/index.html b/client/index.html index 32c667c..5d65dfc 100644 --- a/client/index.html +++ b/client/index.html @@ -5,19 +5,6 @@ - - - - - - - - - - - - - diff --git a/client/layouts/DetailsLayout.tsx b/client/layouts/DetailsLayout.tsx index 78a1e69..3978acb 100644 --- a/client/layouts/DetailsLayout.tsx +++ b/client/layouts/DetailsLayout.tsx @@ -4,13 +4,14 @@ */ import * as React from 'react'; +import { Helmet } from 'react-helmet'; import Ad from '../components/Ad'; import Product from '../components/Product'; import { ProductList } from '../constants/ProductList'; import Pattern from '../constants/Pattern'; import randomItems from '../helpers/randomIterms'; -import useDocumentTitle from '../hooks/useDocumentTitle'; +import slug from '../helpers/slug'; import CoverLoader from '../loaders/CoverLoader'; import Layout from './Layout'; @@ -19,11 +20,22 @@ interface DetailsLayoutProps { } const DetailsLayout: React.FC = ({ pattern, children }) => { - useDocumentTitle(`CSS Layout ∙ ${pattern}`); const products = React.useMemo(() => randomItems(ProductList, 3), []); + const patternSlug = slug(pattern); return ( + + + + + + + + + + +
diff --git a/client/layouts/Layout.tsx b/client/layouts/Layout.tsx index 0633eb8..7cc3915 100644 --- a/client/layouts/Layout.tsx +++ b/client/layouts/Layout.tsx @@ -4,6 +4,7 @@ */ import * as React from 'react'; +import { Helmet } from 'react-helmet'; import Footer from './Footer'; import Header from './Header'; @@ -15,6 +16,22 @@ const Layout: React.FC<{}> = ({ children }) => { return ( <> + + + + + + + + + + + + + + + +
{children}