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

@astrolib/seo -- Meta and Link tags should not use void style #15

Open
ShoGinn opened this issue Apr 30, 2024 · 0 comments
Open

@astrolib/seo -- Meta and Link tags should not use void style #15

ShoGinn opened this issue Apr 30, 2024 · 0 comments

Comments

@ShoGinn
Copy link
Contributor

ShoGinn commented Apr 30, 2024

In:

const createMetaTag = (attributes: Record<string, string>): string => {
const attrs = Object.entries(attributes)
.map(([key, value]) => `${key}="${escape(value)}"`)
.join(" ");
return `<meta ${attrs} />`;
};
const createLinkTag = (attributes: Record<string, string>): string => {
const attrs = Object.entries(attributes)
.map(([key, value]) => `${key}="${escape(value)}"`)
.join(" ");
return `<link ${attrs} />`;
};

Both the <link> and <meta> are using a void style closing method, which is not in the HTML standards:
https://html.spec.whatwg.org/multipage/syntax.html#void-elements

When linting code with html-validate it finds it using this:
https://html-validate.org/rules/void-style.html

I recommend just removing the void-style

const createMetaTag = (attributes: Record<string, string>): string => {
  const attrs = Object.entries(attributes)
    .map(([key, value]) => `${key}="${escape(value)}"`)
    .join(" ");
  return `<meta ${attrs}>`;
};

const createLinkTag = (attributes: Record<string, string>): string => {
  const attrs = Object.entries(attributes)
    .map(([key, value]) => `${key}="${escape(value)}"`)
    .join(" ");
  return `<link ${attrs}>`;
};
Details

When linting just the 404.html from astrowind:

  1:1926  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:1970  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2036  error  Expected omitted end tag <link> instead of self-closing element <link/>  void-style
  1:2083  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2182  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2253  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2297  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2403  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2444  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style
  1:2507  error  Expected omitted end tag <meta> instead of self-closing element <meta/>  void-style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant