Socket
Socket
Sign inDemoInstall

ssg-api

Package Overview
Dependencies
111
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.5 to 1.7.0

dist/src/ConsoleLogger.d.ts

8

CHANGELOG.md

@@ -8,2 +8,10 @@ # Change Log

## [1.7.0] - 2024-01-17
### Added
Add `generator` meta info as `ssg-api` by default.
### Fixed
Serialize meta info.
## [1.6.0] - 2023-12-10

@@ -10,0 +18,0 @@

2

dist/src/index.d.ts

@@ -7,5 +7,5 @@ export * from './SsgConfig.js';

export * from "./step/index.js";
export * from "./DefaultLogger.js";
export * from "./ConsoleLogger";
export * from "./HtmlSsgContext.js";
export * from "./Ssg.js";
export * from "./SsgContextImpl.js";

@@ -7,5 +7,5 @@ export * from './SsgConfig.js';

export * from "./step/index.js";
export * from "./DefaultLogger.js";
export * from "./ConsoleLogger";
export * from "./HtmlSsgContext.js";
export * from "./Ssg.js";
export * from "./SsgContextImpl.js";
import { SsgFile, HtmlSsgFile } from "./util/index.js";
import { ObjectUtil } from "./util/ObjectUtil.js";
import { DefaultLogger } from "./DefaultLogger.js";
import { ConsoleLogger } from "./ConsoleLogger";
import path from "path";
export class SsgContextImpl {
constructor(locale, vars = new Map(), name = SsgContextImpl.DEFAULT_NAME, logger = new DefaultLogger(name), currentFile = undefined) {
constructor(locale, vars = new Map(), name = SsgContextImpl.DEFAULT_NAME, logger = new ConsoleLogger(name), currentFile = undefined) {
this.locale = locale;

@@ -8,0 +8,0 @@ this.vars = vars;

/// <reference types="node" />
import { SsgContext } from "../../SsgContext.js";
import { SsgFile, SsgFileLang } from "./SsgFile.js";
import { JSDOM } from "jsdom";
import { SsgContext } from '../../SsgContext.js';
import { SsgFile, SsgFileLang } from './SsgFile.js';
import { JSDOM } from 'jsdom';
export type HtmlMeta = {

@@ -10,2 +10,3 @@ url?: string;

description?: string;
generator?: string;
};

@@ -40,2 +41,3 @@ export declare enum LinkType {

title?: string | undefined;
static readonly generator = "ssg-api";
constructor(name: string, encoding: BufferEncoding, contents: string, lastModified: Date, lang: SsgFileLang, meta: HtmlMeta, links: HtmlLinks, title?: string | undefined);

@@ -42,0 +44,0 @@ _dom: JSDOM | undefined;

@@ -1,3 +0,3 @@

import { SsgFile } from "./SsgFile.js";
import { JSDOM } from "jsdom";
import { SsgFile } from './SsgFile.js';
import { JSDOM } from 'jsdom';
export var LinkType;

@@ -40,2 +40,17 @@ (function (LinkType) {

serialize() {
const document = this.document;
this.meta.generator = this.meta.generator || 'ssg-api';
for (const metaName in this.meta) {
const newContent = this.meta[metaName];
const contents = newContent ? Array.isArray(newContent) ? newContent : [newContent] : [];
for (const content of contents) {
let metaElem = document.querySelector(`meta[name="${metaName}"]`);
if (!metaElem) {
metaElem = document.createElement('meta');
metaElem.setAttribute('name', metaName);
document.head.append(metaElem);
}
metaElem.setAttribute('content', content);
}
}
return this.dom.serialize();

@@ -63,14 +78,15 @@ }

const doc = dom.window.document;
let titleElem = doc.querySelector("title");
let titleElem = doc.querySelector('title');
if (titleElem) {
const elemTitle = titleElem.textContent ? titleElem.textContent.trim() : "";
const split = elemTitle.lastIndexOf(" - ");
const elemTitle = titleElem.textContent ? titleElem.textContent.trim() : '';
const split = elemTitle.lastIndexOf(' - ');
title = split > 0 ? elemTitle.substring(0, split) : elemTitle;
title = title === null || title === void 0 ? void 0 : title.replace(/\s{2,}/g, " ").replace(/[\n\t]/, " ");
title = title === null || title === void 0 ? void 0 : title.replace(/\s{2,}/g, ' ').replace(/[\n\t]/, ' ');
}
const url = HtmlSsgFile.getMeta("url", doc)[0];
const author = HtmlSsgFile.getMeta("author", doc);
const copyright = HtmlSsgFile.getMeta("copyright", doc)[0];
const description = HtmlSsgFile.getMeta("description", doc)[0];
const meta = { url, author, copyright, description };
const url = HtmlSsgFile.getMeta('url', doc)[0];
const author = HtmlSsgFile.getMeta('author', doc);
const copyright = HtmlSsgFile.getMeta('copyright', doc)[0];
const description = HtmlSsgFile.getMeta('description', doc)[0];
const generator = HtmlSsgFile.getMeta('generator', doc)[0] || HtmlSsgFile.generator;
const meta = { url, author, copyright, description, generator };
const start = HtmlSsgFile.getLink(LinkType.start, doc);

@@ -94,1 +110,2 @@ const contents = HtmlSsgFile.getLink(LinkType.contents, doc);

}
HtmlSsgFile.generator = 'ssg-api';

@@ -5,3 +5,3 @@ {

"author": "Jérôme Beau <javarome@gmail.com> (https://javarome.com)",
"version": "1.6.5",
"version": "1.7.0",
"description": "Static Site Generation TypeScript API",

@@ -33,3 +33,3 @@ "exports": "./dist/src/index.js",

"devDependencies": {
"@types/detect-character-encoding": "~0.7.0",
"@types/detect-character-encoding": "~0.7.2",
"@types/jsdom": "^21.1.3",

@@ -36,0 +36,0 @@ "typescript": "^5.2.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc