Skip to content

Commit

Permalink
Allow setting image: false to disable preview image discover
Browse files Browse the repository at this point in the history
for social metadata

Fixes #5251
  • Loading branch information
dragonstyle committed Nov 30, 2023
1 parent 6b62246 commit 5cb94bb
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
- Add support for `bread-crumbs: true|false` to control whether bread crumbs are displayed. Add support for display of breadcrumbs on full width (non-mobile) pages when `bread-crumbs` is true. Default value is true.
- Add support for `show-item-context` key within the `search` key to control whether page parents are display next to items in search results. Pass `tree`, `parent`, `root`, or boolean (if you pass true, `tree` is the default).
- ([#4739](https://github.com/quarto-dev/quarto-cli/issues/4739)): Improve handling of reader mode at mobile responsive sizes
- ([#5251](https://github.com/quarto-dev/quarto-cli/issues/5251)): Allow individual pages to specify `image: false` to prevent image discover for Twitter and Open Graph metadata.
- ([#5283](https://github.com/quarto-dev/quarto-cli/issues/5283)): Add support for setting `repo-actions: false` in a document to prevent the display of repository actions on a specific page.
- ([#5389](https://github.com/quarto-dev/quarto-cli/issues/5389)): Allow a website project to provide a default image used in social metadata tags.
- ([#5604](https://github.com/quarto-dev/quarto-cli/issues/5604)): Process footer content as blocks.
Expand Down
16 changes: 9 additions & 7 deletions src/project/types/website/website-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function metadataHtmlPostProcessor(
}

// find a preview image if one is not provided
if (metadata[kImage] === undefined) {
if (metadata[kImage] === undefined && format.metadata[kImage] !== false) {
metadata[kImage] = findPreviewImg(doc, true) ||
websiteImage(project.config);
}
Expand Down Expand Up @@ -244,7 +244,7 @@ function opengraphMetadata(
}

// Read open graph data in
if (openGraph && typeof (openGraph) === "object") {
if (openGraph && typeof openGraph === "object") {
[
kTitle,
kDescription,
Expand All @@ -267,7 +267,7 @@ function twitterMetadata(format: Format) {

// populate defaults
const twitterData = mergedSiteAndDocumentData(kTwitterCard, format);
if (twitterData && typeof (twitterData) === "object") {
if (twitterData && typeof twitterData === "object") {
[kTitle, kDescription, kImage, kCreator, kTwitterSite, kCardStyle].forEach(
(key) => {
if (twitterData[key] !== undefined) {
Expand All @@ -285,7 +285,9 @@ function pageMetadata(
): Record<string, unknown> {
const pageTitle = computePageTitle(format, extras) as string;
const pageDescription = format.metadata[kDescription] as string;
const pageImage = format.metadata[kImage] as string;
const pageImage = format.metadata[kImage]
? format.metadata[kImage] as string
: undefined;

return {
[kTitle]: pageTitle,
Expand Down Expand Up @@ -340,13 +342,13 @@ function mergedSiteAndDocumentData(
? format.metadata[key]
: false;

if (typeof (siteMetadata) === "object" && format.metadata[kImage]) {
if (typeof siteMetadata === "object" && format.metadata[kImage]) {
const siteMeta = siteMetadata as Metadata;
siteMeta[kImage] = format.metadata[kImage];
}
if (
typeof (siteMetadata) === "object" &&
typeof (docMetadata) === "object"
typeof siteMetadata === "object" &&
typeof docMetadata === "object"
) {
return mergeConfigs(
siteMetadata,
Expand Down
17 changes: 9 additions & 8 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18108,7 +18108,12 @@ var require_yaml_intelligence_resources = __commonJS({
},
{
name: "image",
schema: "path",
schema: {
anyOf: [
"path",
"boolean"
]
},
tags: {
formats: [
"$html-doc"
Expand Down Expand Up @@ -21217,16 +21222,12 @@ var require_yaml_intelligence_resources = __commonJS({
"The format that this link represents.",
"The title for this link.",
"The icon for this link.",
"The rel for this link.",
"The target for this link.",
"The title for the link.",
"The href for the link.",
"The icon for the link.",
"The format that this link represents.",
"The title for this link.",
"The icon for this link.",
"The rel for this link.",
"The target for this link.",
{
short: "Controls the display of links to notebooks that provided embedded\ncontent or are created from documents.",
long: "Controls the display of links to notebooks that provided embedded\ncontent or are created from documents.\nSpecify <code>false</code> to disable linking to source Notebooks.\nSpecify <code>inline</code> to show links to source notebooks beneath\nthe content they provide. Specify <code>global</code> to show a set of\nglobal links to source notebooks."
Expand Down Expand Up @@ -22534,12 +22535,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 179968,
_internalId: 179698,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 179960,
_internalId: 179690,
type: "enum",
enum: [
"png",
Expand All @@ -22555,7 +22556,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 179967,
_internalId: 179697,
type: "anyOf",
anyOf: [
{
Expand Down
17 changes: 9 additions & 8 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -11080,7 +11080,12 @@
},
{
"name": "image",
"schema": "path",
"schema": {
"anyOf": [
"path",
"boolean"
]
},
"tags": {
"formats": [
"$html-doc"
Expand Down Expand Up @@ -14189,16 +14194,12 @@
"The format that this link represents.",
"The title for this link.",
"The icon for this link.",
"The rel for this link.",
"The target for this link.",
"The title for the link.",
"The href for the link.",
"The icon for the link.",
"The format that this link represents.",
"The title for this link.",
"The icon for this link.",
"The rel for this link.",
"The target for this link.",
{
"short": "Controls the display of links to notebooks that provided embedded\ncontent or are created from documents.",
"long": "Controls the display of links to notebooks that provided embedded\ncontent or are created from documents.\nSpecify <code>false</code> to disable linking to source Notebooks.\nSpecify <code>inline</code> to show links to source notebooks beneath\nthe content they provide. Specify <code>global</code> to show a set of\nglobal links to source notebooks."
Expand Down Expand Up @@ -15506,12 +15507,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 179968,
"_internalId": 179698,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 179960,
"_internalId": 179690,
"type": "enum",
"enum": [
"png",
Expand All @@ -15527,7 +15528,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 179967,
"_internalId": 179697,
"type": "anyOf",
"anyOf": [
{
Expand Down
5 changes: 4 additions & 1 deletion src/resources/schema/document-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
description: URLs that alias this document, when included in a website.

- name: image
schema: path
schema:
anyOf:
- path
- boolean
tags:
formats: [$html-doc]
description:
Expand Down

0 comments on commit 5cb94bb

Please sign in to comment.