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

incl. meta-description in seo.js (closes #1336) #1359

Closed
wants to merge 10 commits into from

Conversation

dhvenema
Copy link
Contributor

No description provided.

src/w3c/seo.js Outdated
@@ -50,5 +50,11 @@ export function run(conf, doc, cb) {
linkElem.setAttribute("href", conf.canonicalURI);
doc.head.appendChild(linkElem);
}
var metaDescription = doc.querySelector("#abstract p:first-of-type")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is universally useful, we should make a new module ("core/seo"). Also, remember to only use "var" for global variables (basically never): always use const unless the variable is going to change , in which case you use let.

export async function run(conf, doc, cb) {
  const metaDescription = doc.querySelector("#abstract p:first-of-type");
  if (!metaDescription) {
    return; // no abstract, so abort early
  }
  // This is not critical, so let's continue other processing first:
  cb();
  await doc.respecIsReady;
  const metaElem = doc.createElement("meta");
  metaElem.name = "description";
  metaElem.content = metaDescription.textContent;
  doc.head.appendChild(metaElem);
}

@marcoscaceres
Copy link
Member

Replaced by #1364

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

Successfully merging this pull request may close these issues.

None yet

2 participants