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

set meta tag name and not property for specified attributes #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion src/main/java/com/arcbees/seo/TagsInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.arcbees.seo;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.arcbees.seo.widget.OgType;
Expand All @@ -29,6 +31,8 @@

public class TagsInjector {
private static final String REL_CANONICAL = "canonical";
private static final List<String> META_WITH_NAME = Arrays.asList("description", "keywords", "robots",
"twitter:title", "twitter:description", "twitter:image", "twitter:card", "twitter:site");
private final Document document;

public TagsInjector() {
Expand Down Expand Up @@ -102,7 +106,11 @@ private void setMetaTag(

if (metaElement == null) {
metaElement = document.createMetaElement();
metaElement.setAttribute("property", property);
if (META_WITH_NAME.contains(property)) {
metaElement.setName(property);
} else {
metaElement.setAttribute("property", property);
}

document.getHead().insertFirst(metaElement);

Expand Down