diff --git a/ecma-logo.png b/ecma-logo.png new file mode 100644 index 00000000..b65fb873 Binary files /dev/null and b/ecma-logo.png differ diff --git a/package.json b/package.json index 799f30ef..9b5d1cee 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "tsc -sourceMap -declarationMap", "build-release": "tsc", - "build-spec": "mkdir -p docs && node bin/ecmarkup.js spec/index.html docs/index.html --assets-dir=docs", + "build-spec": "mkdir -p docs && node bin/ecmarkup.js spec/index.html docs/index.html --assets-dir=docs && cp ecma-logo.png docs/", "prepack": "safe-publish-latest && npm run build-release", "format-spec": "node bin/emu-format.js --write spec/index.html", "test": "mocha", diff --git a/spec/index.html b/spec/index.html index 9aafb1d5..ded4e569 100644 --- a/spec/index.html +++ b/spec/index.html @@ -3,6 +3,7 @@
repository: https://github.com/tc39/ecmarkup +desription: An HTML superset/Markdown subset source format for ECMAScript and related specifications copyright: false markEffects: true@@ -69,6 +70,7 @@
m this.doc.head.prepend(node)
+ : (node: HTMLMetaElement) => metas[metas.length - 1].after(node);
+ if (!metas.some(n => n.getAttribute('property') === 'og:description')) {
+ const description = (
+ this.opts.description ??
+ (this.doc.querySelector('emu-intro') ?? this.doc.querySelector('emu-clause'))?.textContent
+ )
+ ?.slice(0, 300)
+ .trim();
+ if (description) {
+ const meta = this.doc.createElement('meta');
+ meta.setAttribute('property', 'og:description');
+ meta.setAttribute('content', description);
+ insertMetaTag(meta);
+ }
+ }
+ if (!metas.some(n => n.getAttribute('property') === 'og:title')) {
+ const title = this.opts.title ?? this.doc.querySelector('title')?.textContent;
+ if (title) {
+ const meta = this.doc.createElement('meta');
+ meta.setAttribute('property', 'og:title');
+ meta.setAttribute('content', title);
+ insertMetaTag(meta);
+ }
+ }
+ if (!metas.some(n => n.getAttribute('property') === 'og:image')) {
+ const meta = this.doc.createElement('meta');
+ meta.setAttribute('property', 'og:image');
+ meta.setAttribute('content', 'https://tc39.es/ecmarkup/ecma-logo.png');
+ insertMetaTag(meta);
+ }
}
private buildCopyrightBoilerplate() {
diff --git a/src/ecmarkup.ts b/src/ecmarkup.ts
index dace1fff..5ee57920 100644
--- a/src/ecmarkup.ts
+++ b/src/ecmarkup.ts
@@ -27,6 +27,7 @@ export interface Options {
version?: string;
title?: string;
shortname?: string;
+ description?: string;
stage?: string | null;
copyright?: boolean;
date?: Date;
diff --git a/test/baselines/generated-reference/copyright.html b/test/baselines/generated-reference/copyright.html
index 01eb7e25..934ecd7e 100644
--- a/test/baselines/generated-reference/copyright.html
+++ b/test/baselines/generated-reference/copyright.html
@@ -1,5 +1,5 @@
-test title!
+test title!
- Toggle shortcuts help
?
- Toggle "can call user code" annotations
u
diff --git a/test/baselines/generated-reference/proposal-copyright.html b/test/baselines/generated-reference/proposal-copyright.html
index fd61877d..19a5d0c4 100644
--- a/test/baselines/generated-reference/proposal-copyright.html
+++ b/test/baselines/generated-reference/proposal-copyright.html
@@ -1,5 +1,5 @@
-test title!
+test title!
- Toggle shortcuts help
?
- Toggle "can call user code" annotations
u
diff --git a/test/baselines/generated-reference/shortname.html b/test/baselines/generated-reference/shortname.html
index 7191e309..7e842d50 100644
--- a/test/baselines/generated-reference/shortname.html
+++ b/test/baselines/generated-reference/shortname.html
@@ -1,5 +1,5 @@
-test title!
+test title!
- Toggle shortcuts help
?
- Toggle "can call user code" annotations
u
diff --git a/test/baselines/generated-reference/test.html b/test/baselines/generated-reference/test.html
index 226d38f8..73d682e7 100644
--- a/test/baselines/generated-reference/test.html
+++ b/test/baselines/generated-reference/test.html
@@ -1,5 +1,7 @@
-
+
Ecmarkup Test Document
diff --git a/test/baselines/generated-reference/title.html b/test/baselines/generated-reference/title.html
index 994acf7e..47262a40 100644
--- a/test/baselines/generated-reference/title.html
+++ b/test/baselines/generated-reference/title.html
@@ -1,5 +1,5 @@
-test title!
+test title!
- Toggle shortcuts help
?
- Toggle "can call user code" annotations
u
diff --git a/test/baselines/sources/title.html b/test/baselines/sources/title.html
index 2ce8aec2..df9ac95e 100644
--- a/test/baselines/sources/title.html
+++ b/test/baselines/sources/title.html
@@ -1,5 +1,6 @@
title: test title!
+description: a test document
status: draft
version: Draft 1
toc: false