mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 04:42:40 +02:00
fix(core): allow overriding ssr/dev template meta tags (#7952)
This commit is contained in:
parent
c706b23666
commit
94067ce930
6 changed files with 29 additions and 12 deletions
|
@ -12,7 +12,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
|||
|
||||
export default function SiteMetadataDefaults(): JSX.Element {
|
||||
const {
|
||||
siteConfig: {favicon, title},
|
||||
siteConfig: {favicon, title, noIndex},
|
||||
i18n: {currentLocale, localeConfigs},
|
||||
} = useDocusaurusContext();
|
||||
const faviconUrl = useBaseUrl(favicon);
|
||||
|
@ -20,9 +20,17 @@ export default function SiteMetadataDefaults(): JSX.Element {
|
|||
|
||||
return (
|
||||
<Head>
|
||||
{/*
|
||||
charSet + generator are handled in the html templates
|
||||
See https://github.com/facebook/docusaurus/pull/7952
|
||||
<meta charSet="UTF-8" />
|
||||
<meta name="generator" content={`Docusaurus v${docusaurusVersion}`} />
|
||||
*/}
|
||||
<html lang={htmlLang} dir={htmlDir} />
|
||||
<title>{title}</title>
|
||||
<meta property="og:title" content={title} />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
{noIndex && <meta name="robots" content="noindex, nofollow" />}
|
||||
{favicon && <link rel="icon" href={faviconUrl} />}
|
||||
</Head>
|
||||
);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="generator" content="Docusaurus">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<%= htmlWebpackPlugin.options.headTags %>
|
||||
|
|
|
@ -10,15 +10,11 @@ export default `
|
|||
<html <%~ it.htmlAttributes %>>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="generator" content="Docusaurus v<%= it.version %>">
|
||||
<% if (it.noIndex) { %>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<% } %>
|
||||
<%~ it.headTags %>
|
||||
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
||||
<%~ metaAttribute %>
|
||||
<% }); %>
|
||||
<%~ it.headTags %>
|
||||
<% it.stylesheets.forEach((stylesheet) => { %>
|
||||
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
||||
<% }); %>
|
||||
|
|
17
website/_dogfooding/_pages tests/head-metadata.md
Normal file
17
website/_dogfooding/_pages tests/head-metadata.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
## Head Metadata tests
|
||||
|
||||
This page declares the following custom head metadata:
|
||||
|
||||
```html
|
||||
<head>
|
||||
<meta name="generator" value="custom generator name!" />
|
||||
<meta name="viewport" content="initial-scale=1, viewport-fit=cover" />
|
||||
<meta name="robots" content="noindex, nofollow, my-extra-directive" />
|
||||
</head>
|
||||
```
|
||||
|
||||
<head>
|
||||
<meta name="generator" value="custom generator name!" />
|
||||
<meta name="viewport" content="initial-scale=1, viewport-fit=cover" />
|
||||
<meta name="robots" content="noindex, nofollow, my-extra-directive" />
|
||||
</head>
|
|
@ -29,3 +29,4 @@ import Readme from "../README.md"
|
|||
- [TOC tests](/tests/pages/page-toc-tests)
|
||||
- [Tabs tests](/tests/pages/tabs-tests)
|
||||
- [z-index tests](/tests/pages/z-index-tests)
|
||||
- [Head metadata tests](/tests/pages/head-metadata)
|
||||
|
|
|
@ -509,15 +509,11 @@ module.exports = {
|
|||
<html <%~ it.htmlAttributes %>>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="generator" content="Docusaurus v<%= it.version %>">
|
||||
<% if (it.noIndex) { %>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<% } %>
|
||||
<%~ it.headTags %>
|
||||
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
||||
<%~ metaAttribute %>
|
||||
<% }); %>
|
||||
<%~ it.headTags %>
|
||||
<% it.stylesheets.forEach((stylesheet) => { %>
|
||||
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
||||
<% }); %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue