Comparing version 1.7.0 to 1.7.1
@@ -52,2 +52,4 @@ /// <reference types="node" /> | ||
serialize(): string; | ||
private updateLinkTags; | ||
private updateMetaTags; | ||
set dom(newDom: JSDOM); | ||
@@ -54,0 +56,0 @@ get contents(): string; |
@@ -40,6 +40,32 @@ import { SsgFile } from './SsgFile.js'; | ||
serialize() { | ||
this.updateMetaTags(); | ||
this.updateLinkTags(); | ||
return this.dom.serialize(); | ||
} | ||
updateLinkTags() { | ||
const document = this.document; | ||
this.meta.generator = this.meta.generator || 'ssg-api'; | ||
for (const metaName in this.meta) { | ||
const newContent = this.meta[metaName]; | ||
const links = this.links; | ||
for (const linkRel in links) { | ||
const link = links[linkRel]; | ||
if (link) { | ||
const rel = link.type; | ||
let linkElem = document.querySelector(`link[rel="${rel}"]`); | ||
if (!linkElem) { | ||
linkElem = document.createElement('link'); | ||
linkElem.setAttribute('rel', rel); | ||
document.head.append(linkElem); | ||
} | ||
linkElem.setAttribute('href', link.url); | ||
if (link.text) { | ||
linkElem.setAttribute('title', link.text); | ||
} | ||
} | ||
} | ||
} | ||
updateMetaTags() { | ||
const document = this.document; | ||
const meta = this.meta; | ||
meta.generator = meta.generator || 'ssg-api'; | ||
for (const metaName in meta) { | ||
const newContent = meta[metaName]; | ||
const contents = newContent ? Array.isArray(newContent) ? newContent : [newContent] : []; | ||
@@ -56,3 +82,2 @@ for (const content of contents) { | ||
} | ||
return this.dom.serialize(); | ||
} | ||
@@ -59,0 +84,0 @@ set dom(newDom) { |
@@ -5,3 +5,3 @@ { | ||
"author": "Jérôme Beau <javarome@gmail.com> (https://javarome.com)", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Static Site Generation TypeScript API", | ||
@@ -8,0 +8,0 @@ "exports": "./dist/src/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80423
2000