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 @@ Ecmarkup
 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 @@

Options

`version`Document version, for example "6<sup>th</sup> Edition" (which renders like "6th Edition") or "Draft 1". `date`Timestamp of document rendering, used for various pieces of boilerplate. Defaults to the value of the `SOURCE_DATE_EPOCH` environment variable (as a number of second since the POSIX epoch) if it exists, otherwise to the current date and time. `shortname`Document shortname, for example "ECMA-262". If present and `status` is "draft", `version` defaults to "Draft shortname". + `description`Brief description to be used for link previews in social media and the like. `location`URL of this document. Used in conjunction with the biblio file to support inbound references from other documents. `copyright`Emit copyright and software license information. Boolean, default true. `contributors`Contributors to this specification, i.e. those who own the copyright. If your proposal includes text from any Ecma specification, this should include "Ecma International". diff --git a/src/Spec.ts b/src/Spec.ts index a3865d07..ea2c8c5f 100644 --- a/src/Spec.ts +++ b/src/Spec.ts @@ -1438,6 +1438,42 @@ ${this.opts.multipage ? `
  • Navigate to/from multipagem 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" annotationsu
    • 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" annotationsu
      • 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" annotationsu
        • 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" annotationsu
          • 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 @@