Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#39 - Featured Article component does not pull title and description from the referenced article #40

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions blocks/featured-article/featured-article.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
getMetadata,
} from '../../scripts/lib-franklin.js';

/**
* Loads a fragment.
* @param {string} path The path to the fragment
Expand All @@ -18,6 +14,18 @@ async function loadFragment(path) {
return null;
}

/**
* Retrieves the content of metadata tags.
* @param {string} name The metadata name (or property)
* @param doc Document object to query for the metadata. Defaults to the window's document
* @returns {string} The metadata value(s)
*/
function getMetadata(name, doc = document) {
const attr = name && name.includes(':') ? 'property' : 'name';
const meta = [...doc.head.querySelectorAll(`meta[${attr}="${name}"]`)].map((m) => m.content).join(', ');
return meta || '';
}

/**
* @param {HTMLElement} $block The header block element
*/
Expand Down
4 changes: 2 additions & 2 deletions docs/authoring/documents.zip
Git LFS file not shown
Loading