Skip to content

Commit

Permalink
fix(metadata): fix setting of meta and other tags
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati committed Aug 8, 2017
1 parent 96bd616 commit 8dc8558
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"build": "ngc tsconfig.json",
"documentation": "yuidoc . -c yuidoc.json",
"start": "npm run build",
"release:major": "changelog -M && git add . && git commit -m 'chore(release): major version release' && npm version major && git push origin && git push origin --tags",
"release:minor": "changelog -m && git add . && git commit -m 'chore(release): minor version release' && npm version minor && git push origin && git push origin --tags",
"release:patch": "changelog -p && git add . && git commit -m 'chore(release): patch version release' && npm version patch && git push origin && git push origin --tags"
"release:major": "npm run build && changelog -M && git add . && git commit -m 'chore(release): major version release' && npm version major && git push origin && git push origin --tags",
"release:minor": "npm run build && changelog -m && git add . && git commit -m 'chore(release): minor version release' && npm version minor && git push origin && git push origin --tags",
"release:patch": "npm run build && changelog -p && git add . && git commit -m 'chore(release): patch version release' && npm version patch && git push origin && git push origin --tags"
},
"repository": {
"type": "git",
Expand Down
14 changes: 9 additions & 5 deletions src/ngmeta.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export class NGMeta {
set canonical(canonicalURL: string) {
try {
this._removeTag('[rel=\'canonical\']');
const canonical = this._dom.createElement(this._document.head, 'link');
const canonical: HTMLElement = this._dom.createElement('link');
this._dom.setAttribute(canonical, 'rel', 'canonical');
this._dom.setAttribute(canonical, 'href', canonicalURL);
this._dom.appendChild(this._document.head, canonical);
} catch (e) { }
}

Expand Down Expand Up @@ -93,11 +94,14 @@ export class NGMeta {
try {
if (typeof metaData.attribute === 'string' && typeof metaData.type === 'string' && typeof metaData.content === 'string') {
this._removeTag(`[${metaData.attribute}='${metaData.type}']`);
const meta = this._dom.createElement(this._document.head, 'meta');
const meta: HTMLElement = this._dom.createElement('meta');
this._dom.setAttribute(meta, metaData.attribute, metaData.type);
this._dom.setAttribute(meta, 'content', metaData.content);
this._dom.appendChild(this._document.head, meta);
}
} catch (e) { }
} catch (e) {
console.log(e)
}
}

/**
Expand Down Expand Up @@ -150,8 +154,8 @@ export class NGMeta {
*/
private _removeTag(tagSelector: string): void {
try {
let tag = this._dom.querySelector(this._document.head, tagSelector);
this._dom.removeChild(tag, this._document.head);
const tag: HTMLElement = this._dom.querySelector(this._document.head, tagSelector);
this._dom.remove(tag);
} catch (e) { }
}

Expand Down

0 comments on commit 8dc8558

Please sign in to comment.