mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 18:58:36 +02:00
refactor(v2): remove type attribute from link and script tags (#4907)
* refactor(v2): remove type attribute from link and script tags * minor TS fix * stylesheets.type => optional Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
d81d43c247
commit
55e9bd8ac9
7 changed files with 11 additions and 18 deletions
|
@ -178,9 +178,6 @@ export default function docusaurusThemeClassic(
|
||||||
preBodyTags: [
|
preBodyTags: [
|
||||||
{
|
{
|
||||||
tagName: 'script',
|
tagName: 'script',
|
||||||
attributes: {
|
|
||||||
type: 'text/javascript',
|
|
||||||
},
|
|
||||||
innerHTML: noFlashColorMode(colorMode),
|
innerHTML: noFlashColorMode(colorMode),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = `
|
||||||
<%~ metaAttribute %>
|
<%~ metaAttribute %>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% it.stylesheets.forEach((stylesheet) => { %>
|
<% it.stylesheets.forEach((stylesheet) => { %>
|
||||||
<link rel="stylesheet" type="text/css" href="<%= it.baseUrl %><%= stylesheet %>" />
|
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% it.scripts.forEach((script) => { %>
|
<% it.scripts.forEach((script) => { %>
|
||||||
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
|
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
|
||||||
|
@ -32,7 +32,7 @@ module.exports = `
|
||||||
<%~ it.appHtml %>
|
<%~ it.appHtml %>
|
||||||
</div>
|
</div>
|
||||||
<% it.scripts.forEach((script) => { %>
|
<% it.scripts.forEach((script) => { %>
|
||||||
<script type="text/javascript" src="<%= it.baseUrl %><%= script %>"></script>
|
<script src="<%= it.baseUrl %><%= script %>"></script>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<%~ it.postBodyTags %>
|
<%~ it.postBodyTags %>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -150,7 +150,7 @@ const ConfigSchema = Joi.object({
|
||||||
Joi.string(),
|
Joi.string(),
|
||||||
Joi.object({
|
Joi.object({
|
||||||
href: Joi.string().required(),
|
href: Joi.string().required(),
|
||||||
type: Joi.string().required(),
|
type: Joi.string(),
|
||||||
}).unknown(),
|
}).unknown(),
|
||||||
),
|
),
|
||||||
clientModules: Joi.array().items(Joi.string()),
|
clientModules: Joi.array().items(Joi.string()),
|
||||||
|
|
|
@ -24,6 +24,7 @@ import loadThemeAlias from './themes';
|
||||||
import {
|
import {
|
||||||
DocusaurusConfig,
|
DocusaurusConfig,
|
||||||
DocusaurusSiteMetadata,
|
DocusaurusSiteMetadata,
|
||||||
|
HtmlTagObject,
|
||||||
LoadContext,
|
LoadContext,
|
||||||
PluginConfig,
|
PluginConfig,
|
||||||
Props,
|
Props,
|
||||||
|
@ -194,24 +195,23 @@ export async function load(
|
||||||
const stylesheetsTags = stylesheets.map((source) =>
|
const stylesheetsTags = stylesheets.map((source) =>
|
||||||
typeof source === 'string'
|
typeof source === 'string'
|
||||||
? `<link rel="stylesheet" href="${source}">`
|
? `<link rel="stylesheet" href="${source}">`
|
||||||
: {
|
: ({
|
||||||
tagName: 'link',
|
tagName: 'link',
|
||||||
attributes: {
|
attributes: {
|
||||||
rel: 'stylesheet',
|
rel: 'stylesheet',
|
||||||
...source,
|
...source,
|
||||||
},
|
},
|
||||||
},
|
} as HtmlTagObject),
|
||||||
);
|
);
|
||||||
const scriptsTags = scripts.map((source) =>
|
const scriptsTags = scripts.map((source) =>
|
||||||
typeof source === 'string'
|
typeof source === 'string'
|
||||||
? `<script type="text/javascript" src="${source}"></script>`
|
? `<script src="${source}"></script>`
|
||||||
: {
|
: ({
|
||||||
tagName: 'script',
|
tagName: 'script',
|
||||||
attributes: {
|
attributes: {
|
||||||
type: 'text/javascript',
|
|
||||||
...source,
|
...source,
|
||||||
},
|
},
|
||||||
},
|
} as HtmlTagObject),
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
headTags: [...stylesheetsTags, ...scriptsTags],
|
headTags: [...stylesheetsTags, ...scriptsTags],
|
||||||
|
|
|
@ -406,7 +406,7 @@ module.exports = {
|
||||||
<%~ metaAttribute %>
|
<%~ metaAttribute %>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% it.stylesheets.forEach((stylesheet) => { %>
|
<% it.stylesheets.forEach((stylesheet) => { %>
|
||||||
<link rel="stylesheet" type="text/css" href="<%= it.baseUrl %><%= stylesheet %>" />
|
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<% it.scripts.forEach((script) => { %>
|
<% it.scripts.forEach((script) => { %>
|
||||||
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
|
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
|
||||||
|
@ -421,7 +421,7 @@ module.exports = {
|
||||||
<span>Custom markup</span>
|
<span>Custom markup</span>
|
||||||
</div>
|
</div>
|
||||||
<% it.scripts.forEach((script) => { %>
|
<% it.scripts.forEach((script) => { %>
|
||||||
<script type="text/javascript" src="<%= it.baseUrl %><%= script %>"></script>
|
<script src="<%= it.baseUrl %><%= script %>"></script>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
<%~ it.postBodyTags %>
|
<%~ it.postBodyTags %>
|
||||||
</body>
|
</body>
|
||||||
|
@ -445,7 +445,6 @@ module.exports = {
|
||||||
// Object format.
|
// Object format.
|
||||||
{
|
{
|
||||||
href: 'http://mydomain.com/style.css',
|
href: 'http://mydomain.com/style.css',
|
||||||
type: 'text/css',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,7 +71,6 @@ Include the KaTeX CSS in your config under `stylesheets`:
|
||||||
stylesheets: [
|
stylesheets: [
|
||||||
{
|
{
|
||||||
href: "https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css",
|
href: "https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css",
|
||||||
type: "text/css",
|
|
||||||
integrity: "sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc",
|
integrity: "sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc",
|
||||||
crossorigin: "anonymous",
|
crossorigin: "anonymous",
|
||||||
},
|
},
|
||||||
|
@ -108,7 +107,6 @@ module.exports = {
|
||||||
+ stylesheets: [
|
+ stylesheets: [
|
||||||
+ {
|
+ {
|
||||||
+ href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
|
+ href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
|
||||||
+ type: 'text/css',
|
|
||||||
+ integrity:
|
+ integrity:
|
||||||
+ 'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
|
+ 'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
|
||||||
+ crossorigin: 'anonymous',
|
+ crossorigin: 'anonymous',
|
||||||
|
|
|
@ -57,7 +57,6 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
|
||||||
stylesheets: [
|
stylesheets: [
|
||||||
{
|
{
|
||||||
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
|
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
|
||||||
type: 'text/css',
|
|
||||||
integrity:
|
integrity:
|
||||||
'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
|
'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
|
||||||
crossorigin: 'anonymous',
|
crossorigin: 'anonymous',
|
||||||
|
|
Loading…
Add table
Reference in a new issue