Skip to content

Commit

Permalink
Add meta description for seo
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Aug 1, 2019
1 parent 080b272 commit b8a9f8e
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 8 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package.json
content/
prism.js
template.html
1 change: 1 addition & 0 deletions content/about/browser-support.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Browser Support
permalink: '/about/browser-support'
description: "Preact supports all modern browsers (Chrome, Firefox, Safari, Edge) and IE11 out of the box."
---

# Browser Support
Expand Down
1 change: 1 addition & 0 deletions content/about/cli.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Preact CLI
permalink: '/about/cli'
description: 'Learn how to use preact-cli with Preact to speed up your development workflow'
---

# Preact CLI
Expand Down
1 change: 1 addition & 0 deletions content/about/demos-examples.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Demos & Examples
permalink: '/about/demos-examples'
description: 'Collection of demos and example Preact applications'
---

# Demos & Examples
Expand Down
1 change: 1 addition & 0 deletions content/about/libraries-addons.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Libraries & Add-ons
permalink: '/about/addons-libraries'
description: 'Collection of libraries and addons that work well with Preact'
---

# Libraries & Add-ons
Expand Down
1 change: 1 addition & 0 deletions content/about/project-goals.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Project Goals
permalink: '/about/project-goals'
description: 'Read more about Preact's project goals'
---

# Preact's Goals
Expand Down
1 change: 1 addition & 0 deletions content/about/we-are-using.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: We Are Using
title: Who's using Preact?
permalink: '/about/we-are-using'
description: 'Companies who are proudly using Preact'
---

<style>
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/api-reference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: API Reference
description: 'Learn more about all exported functions of the Preact module'
---

# API Reference <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/components.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Components
descriptions: 'Components are the heart of any Preact application. Learn how to create them and use them to compose UIs together'
---

# Components <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/context.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Context
description: 'Context allows you to pass props through intermediate components. This documents describes both the new and the old API'
---

# Context<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/debugging.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Debugging Preact Apps
description: 'How to debug Preact applications when something goes wrong.'
---

# Debugging Preact Apps <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/differences-to-react.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Differences to React
permalink: '/guide/differences-to-react'
description: 'What are the differences between Preact and React. This document describes them in detail'
---

# Differences to React <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/external-dom-mutations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: External DOM Mutations
permalink: '/guide/external-dom-mutations'
description: 'How to integrate Preact with jQuery and other JavaScript snippets which mutate the DOM directly'
---

# External DOM Mutations <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/forms.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Forms
description: 'How to build awesome forms in Preact that work anywhere.'
---

# Forms <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Getting Started
description: 'How to get started with Preact. We'll learn how to setup the tooling (if any) and get going with writing an application.'
---

# Getting Started <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/hooks.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Hooks
description: 'Hooks in Preact allow you to compose behaviours together and re-use that logic in different components.'
---

# Hooks <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/progressive-web-apps.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Progressive Web Apps
permalink: '/guide/progressive-web-apps'
description: 'Progressive Web Apps (PWA) allow you to ship your app offline. They work pretty well with Preact'
---

# Progressive Web Apps<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/refs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: References
description: 'References can be used to access raw DOM nodes that Preact has rendered'
---

# References<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/server-side-rendering.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Server-Side Rendering
description: 'Render your Preact application on the server to show content to users quicker.'
---

# Server-Side Rendering<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/switching-to-preact.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Switching to Preact from React
permalink: '/guide/switching-to-preact'
description: 'Everything you need to know to switch from React to Preact.'
---

# Switching to Preact (from React)<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Tutorial
description: 'Write your first Preact application'
---

# Tutorial<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/unit-testing-with-enzyme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Unit Testing with Enzyme
permalink: '/guide/unit-testing-with-enzyme'
description: 'Testing Preact applications made easy with enzyme'
---

# Unit Testing with Enzyme<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/upgrade-guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Upgrading from Preact 8.x
description: 'Upgrade your Preact 8.x application to Preact X'
---

# Upgrading from Preact 8.x <!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/guide/v10/web-components.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
name: Web Components
description: 'How to use webcomponents with Preact.'
---

# Web Components<!-- omit in toc -->
Expand Down
1 change: 1 addition & 0 deletions content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: home
title: Preact
show_title: false
toc: false
description: 'Preact is a fast 3kB alternative to React with the same modern API'
---

<jumbotron>
Expand Down
28 changes: 20 additions & 8 deletions src/components/controllers/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import Footer from '../../footer';
import Sidebar from './sidebar';
import Hydrator from '../../../lib/hydrator';
import EditThisPage from '../../edit-button';
import { getPrerenderData, InjectPrerenderData } from '../../../lib/prerender-data';
import {
getPrerenderData,
InjectPrerenderData
} from '../../../lib/prerender-data';
import { isDocPage } from '../../../lib/docs';
import { useStore } from '../../store-adapter';

Expand All @@ -26,8 +29,20 @@ export function useTitle(title) {
}, [title]);
}

const noop = () => {};
/**
* Set the meta description tag content
* @param {string} text
*/
export function useDescription(text) {
useEffect(() => {
const el = document.querySelector('meta[name=description]');
if (text && el) {
el.setAttribute('content', text);
}
}, [text]);
}

const noop = () => {};

export function usePage(route) {
// on the server, pass data down through the tree to avoid repeated FS lookups
Expand All @@ -43,7 +58,7 @@ export function usePage(route) {
}

const [current, setCurrent] = useState(getContent(route));

const bootData = getPrerenderData(current);

const [hydrated, setHydrated] = useState(!!bootData);
Expand All @@ -60,6 +75,7 @@ export function usePage(route) {
}, [getContent(route)]);

useTitle(meta.title);
useDescription(meta.description);

let didLoad = false;
function onLoad({ meta }) {
Expand Down Expand Up @@ -130,11 +146,7 @@ export default function Page({ route }) {
toc={toc}
/>
<div class={style.inner}>
<Hydrator
boot={isReady}
component={EditThisPage}
show={canEdit}
/>
<Hydrator boot={isReady} component={EditThisPage} show={canEdit} />
<Hydrator
component={Title}
boot={isReady}
Expand Down
1 change: 1 addition & 0 deletions src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="manifest" href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json">
<meta name="description" content="Preact is a fast 3kB alternative to React with the same modern API.">
<% if (htmlWebpackPlugin.options.manifest.theme_color) { %>
<meta name="theme-color" content="<%= htmlWebpackPlugin.options.manifest.theme_color %>">
<% } %>
Expand Down

0 comments on commit b8a9f8e

Please sign in to comment.