Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(v2): remove type attribute from link and script tags #4907

Merged
merged 3 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/docusaurus-theme-classic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export default function docusaurusThemeClassic(
preBodyTags: [
{
tagName: 'script',
attributes: {
type: 'text/javascript',
},
innerHTML: noFlashColorMode(colorMode),
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/src/client/templates/ssr.html.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = `
<%~ metaAttribute %>
<% }); %>
<% 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) => { %>
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
Expand All @@ -32,7 +32,7 @@ module.exports = `
<%~ it.appHtml %>
</div>
<% it.scripts.forEach((script) => { %>
<script type="text/javascript" src="<%= it.baseUrl %><%= script %>"></script>
<script src="<%= it.baseUrl %><%= script %>"></script>
<% }); %>
<%~ it.postBodyTags %>
</body>
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/configValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const ConfigSchema = Joi.object({
Joi.string(),
Joi.object({
href: Joi.string().required(),
type: Joi.string().required(),
type: Joi.string(),
}).unknown(),
),
clientModules: Joi.array().items(Joi.string()),
Expand Down
12 changes: 6 additions & 6 deletions packages/docusaurus/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import loadThemeAlias from './themes';
import {
DocusaurusConfig,
DocusaurusSiteMetadata,
HtmlTagObject,
LoadContext,
PluginConfig,
Props,
Expand Down Expand Up @@ -194,24 +195,23 @@ export async function load(
const stylesheetsTags = stylesheets.map((source) =>
typeof source === 'string'
? `<link rel="stylesheet" href="${source}">`
: {
: ({
tagName: 'link',
attributes: {
rel: 'stylesheet',
...source,
},
},
} as HtmlTagObject),
);
const scriptsTags = scripts.map((source) =>
typeof source === 'string'
? `<script type="text/javascript" src="${source}"></script>`
: {
? `<script src="${source}"></script>`
: ({
tagName: 'script',
attributes: {
type: 'text/javascript',
slorber marked this conversation as resolved.
Show resolved Hide resolved
...source,
},
},
} as HtmlTagObject),
);
return {
headTags: [...stylesheetsTags, ...scriptsTags],
Expand Down
5 changes: 2 additions & 3 deletions website/docs/api/docusaurus.config.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ module.exports = {
<%~ metaAttribute %>
<% }); %>
<% 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) => { %>
<link rel="preload" href="<%= it.baseUrl %><%= script %>" as="script">
Expand All @@ -421,7 +421,7 @@ module.exports = {
<span>Custom markup</span>
</div>
<% it.scripts.forEach((script) => { %>
<script type="text/javascript" src="<%= it.baseUrl %><%= script %>"></script>
<script src="<%= it.baseUrl %><%= script %>"></script>
<% }); %>
<%~ it.postBodyTags %>
</body>
Expand All @@ -445,7 +445,6 @@ module.exports = {
// Object format.
{
href: 'http://mydomain.com/style.css',
type: 'text/css',
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Include the KaTeX CSS in your config under `stylesheets`:
stylesheets: [
{
href: "https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css",
type: "text/css",
integrity: "sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc",
crossorigin: "anonymous",
},
Expand Down Expand Up @@ -108,7 +107,6 @@ module.exports = {
+ stylesheets: [
+ {
+ href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
+ type: 'text/css',
+ integrity:
+ 'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
+ crossorigin: 'anonymous',
Expand Down
1 change: 0 additions & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc',
crossorigin: 'anonymous',
Expand Down