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

Labs #419

Merged
merged 7 commits into from
Nov 18, 2023
Merged

Labs #419

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
15 changes: 15 additions & 0 deletions blocks/labs/labs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.labs {
padding: 10px 16px;
margin-bottom: 16px;
background-color: #e6118a;
color: #fff;
border-radius: var(--image-border-radius-l);
font-size: var(--type-body-s-size);
line-height: var(--type-body-s-lh);
}

.labs .header {
font-weight: 700;
font-size: var(--type-heading-m-size);
text-transform: uppercase;
}
7 changes: 7 additions & 0 deletions blocks/labs/labs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function decorate(block) {
const header = document.createElement('div');
header.className = 'header';
header.textContent = 'Early-access technology';
block.innerHTML = `Ask us about this feature from the ${block.textContent.trim()} labs on your Slack channel!`;
block.prepend(header);
}
8 changes: 5 additions & 3 deletions helix-query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ indices:
parseTimestamp(headers['last-modified'], 'ddd, DD MMM YYYY hh:mm:ss GMT')
docpages:
target: /docpages-index
include:
include:
- /docs/**
- /developer/**
properties:
Expand All @@ -38,6 +38,10 @@ indices:
select: head > meta[name="description"]
value: |
attribute(el, 'content')
labs:
select: head > meta[name="labs"]
value: |
attribute(el, 'content')
lastModified:
select: none
value: |
Expand All @@ -46,5 +50,3 @@ indices:
select: main
value: |
textContent(el)


14 changes: 14 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
// get all links that end with .svg
const svgLinks = main.querySelectorAll('div.default-content-wrapper a[href$=".svg"]');
Array.from(svgLinks).forEach((svg) => {
console.log(svg.parentElement.parentElement);

Check warning on line 517 in scripts/scripts.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Unexpected console statement
const svgHref = new URL(svg.href).pathname;

const svgEl = createTag('img', {
Expand Down Expand Up @@ -574,6 +574,20 @@

await window.hlx.plugins.run('loadEager');

// labs banner
const labs = getMetadata('labs');
if (labs) {
const labsBanner = buildBlock('labs', labs);
const h1 = document.querySelector('h1');
if (h1) {
// insert above title
h1.parentElement.insertBefore(labsBanner, h1);
} else {
// insert at top of page
document.querySelector('main > div').append(labsBanner);
}
}

const main = doc.querySelector('main');
if (main) {
decorateMain(main);
Expand Down
Loading