Skip to content

Commit

Permalink
Merge branch 'main' into quote
Browse files Browse the repository at this point in the history
  • Loading branch information
buuhuu committed Nov 4, 2024
2 parents b242dea + 67dd247 commit f671dc6
Show file tree
Hide file tree
Showing 44 changed files with 1,508 additions and 476 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.js]
indent_size = 2

[*.css]
indent_size = 4
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Please always provide the [GitHub issue(s)](../issues) your PR is for, as well a
Fix #<gh-issue-id>

Test URLs:
- Before: https://main--{repo}--{owner}.hlx.live/
- After: https://<branch>--{repo}--{owner}.hlx.live/
- Before: https://main--{repo}--{owner}.aem.live/
- After: https://<branch>--{repo}--{owner}.aem.live/
1 change: 1 addition & 0 deletions .hlxignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ LICENSE
package.json
package-lock.json
test/*
_*
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node .husky/pre-commit.mjs
20 changes: 20 additions & 0 deletions .husky/pre-commit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { exec } from "node:child_process";

const run = (cmd) => new Promise((resolve, reject) => exec(
cmd,
(error, stdout) => {
if (error) reject(error);
else resolve(stdout);
}
));

const changeset = await run('git diff --cached --name-only --diff-filter=ACMR');
const modifiedFiles = changeset.split('\n').filter(Boolean);

// check if there are any model files staged
const modifledPartials = modifiedFiles.filter((file) => file.match(/(^|\/)_.*.json/));
if (modifledPartials.length > 0) {
const output = await run('npm run build:json --silent');
console.log(output);
await run('git add component-models.json component-definition.json component-filters.json');
}
9 changes: 5 additions & 4 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<meta property="og:title" content="Page not found">
<script src="/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script type="module">
import { sampleRUM } from '/scripts/aem.js';

window.addEventListener('load', () => {
if (document.referrer) {
const { origin, pathname } = new URL(document.referrer);
Expand All @@ -26,9 +24,12 @@
btnContainer.append(backBtn);
}
}
sampleRUM('404', { source: document.referrer });
});
</script>
<script type="module">
import { sampleRUM } from '/scripts/aem.js';
sampleRUM('404', { source: document.referrer });
</script>
<link rel="stylesheet" href="/styles/styles.css">
<style>
main.error {
Expand All @@ -42,7 +43,7 @@
}

main.error .error-number text {
font-family: var(--fixed-font-family);
font-family: monospace;
}
</style>
<link rel="stylesheet" href="/styles/lazy-styles.css">
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Your project's description...

## Environments
- Preview: https://main--{repo}--{owner}.hlx.page/
- Live: https://main--{repo}--{owner}.hlx.live/
- Preview: https://main--{repo}--{owner}.aem.page/
- Live: https://main--{repo}--{owner}.aem.live/

## Installation

Expand All @@ -24,3 +24,19 @@ npm run lint
1. Install the [AEM CLI](https://github.com/adobe/helix-cli): `npm install -g @adobe/aem-cli`
1. Start AEM Proxy: `aem up` (opens your browser at `http://localhost:3000`)
1. Open the `{repo}` directory in your favorite IDE and start coding :)

## Prerequisites

- nodejs 18.3.x or newer
- AEM Cloud Service release 2024.8 or newer (>= `17465`)

## Resources

### Documentation
- [Getting Started Guide](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/edge-delivery/wysiwyg-authoring/edge-dev-getting-started)
- [Creating Blocks](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/edge-delivery/wysiwyg-authoring/create-block)
- [Content Modelling](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/edge-delivery/wysiwyg-authoring/content-modeling)
- [Working with Tabular Data / Spreadsheets](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/edge-delivery/wysiwyg-authoring/tabular-data)

### Presentations and Recordings
- [Getting started with AEM Authoring and Edge Delivery Services](https://experienceleague.adobe.com/en/docs/events/experience-manager-gems-recordings/gems2024/aem-authoring-and-edge-delivery)
63 changes: 63 additions & 0 deletions blocks/cards/_cards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"definitions": [
{
"title": "Cards",
"id": "cards",
"plugins": {
"xwalk": {
"page": {
"resourceType": "core/franklin/components/block/v1/block",
"template": {
"name": "Cards",
"filter": "cards"
}
}
}
}
},
{
"title": "Card",
"id": "card",
"plugins": {
"xwalk": {
"page": {
"resourceType": "core/franklin/components/block/v1/block/item",
"template": {
"name": "Card",
"model": "card"
}
}
}
}
}
],
"models": [
{
"id": "card",
"fields": [
{
"component": "reference",
"valueType": "string",
"name": "image",
"label": "Image",
"multi": false
},
{
"component": "richtext",
"name": "text",
"value": "",
"label": "Text",
"valueType": "string"
}
]
}
],
"filters": [
{
"id": "cards",
"components": [
"card"
]
}
]
}
10 changes: 3 additions & 7 deletions blocks/cards/cards.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
margin: 0;
padding: 0;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(278px, 1fr));
grid-gap: 16px;
grid-template-columns: repeat(auto-fill, minmax(257px, 1fr));
grid-gap: 24px;
}

.cards > ul > li {
border: 1px solid var(--dark-color);
border: 1px solid #dadada;
background-color: var(--background-color);
}

Expand All @@ -20,10 +20,6 @@
line-height: 0;
}

.cards .cards-card-body > *:first-child {
margin-top: 0;
}

.cards > ul > li img {
width: 100%;
aspect-ratio: 4 / 3;
Expand Down
57 changes: 57 additions & 0 deletions blocks/columns/_columns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"definitions": [
{
"title": "Columns",
"id": "columns",
"plugins": {
"xwalk": {
"page": {
"resourceType": "core/franklin/components/columns/v1/columns",
"template": {
"columns": "2",
"rows": "1"
}
}
}
}
}
],
"models": [
{
"id": "columns",
"fields": [
{
"component": "text",
"valueType": "number",
"name": "columns",
"value": "",
"label": "Columns"
},
{
"component": "text",
"valueType": "number",
"name": "rows",
"value": "",
"label": "Rows"
}
]
}
],
"filters": [
{
"id": "columns",
"components": [
"column"
]
},
{
"id": "column",
"components": [
"text",
"image",
"button",
"title"
]
}
]
}
2 changes: 1 addition & 1 deletion blocks/columns/columns.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
.columns > div {
align-items: center;
flex-direction: unset;
gap: 32px;
gap: 24px;
}

.columns > div > div {
Expand Down
14 changes: 10 additions & 4 deletions blocks/footer/footer.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
footer {
padding: 2rem;
background-color: var(--light-color);
font-size: var(--body-font-size-s);
font-size: var(--body-font-size-xs);
}

footer .footer {
max-width: 1200px;
footer .footer > div {
margin: auto;
max-width: 1200px;
padding: 40px 24px 24px;
}

footer .footer p {
margin: 0;
}

@media (width >= 900px) {
footer .footer > div {
padding: 40px 32px 24px;
}
}
32 changes: 32 additions & 0 deletions blocks/fragment/_fragment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"definitions": [
{
"title": "Fragment",
"id": "fragment",
"plugins": {
"xwalk": {
"page": {
"resourceType": "core/franklin/components/block/v1/block",
"template": {
"name": "Fragment",
"model": "fragment"
}
}
}
}
}
],
"models": [
{
"id": "fragment",
"fields": [
{
"component": "aem-content",
"name": "reference",
"label": "Reference"
}
]
}
],
"filters": []
}
14 changes: 1 addition & 13 deletions blocks/fragment/fragment.css
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
/* suppress nested section padding */
.fragment-wrapper > .section {
padding-left: 0;
padding-right: 0;
}

.fragment-wrapper > .section:first-of-type {
padding-top: 0;
}

.fragment-wrapper > .section:last-of-type {
padding-bottom: 0;
}
/* stylelint-disable no-empty-source */
11 changes: 7 additions & 4 deletions blocks/fragment/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../scripts/scripts.js';

import {
loadBlocks,
loadSections,
} from '../../scripts/aem.js';

/**
Expand All @@ -19,6 +19,8 @@ import {
*/
export async function loadFragment(path) {
if (path && path.startsWith('/')) {
// eslint-disable-next-line no-param-reassign
path = path.replace(/(\.plain)?\.html/, '');
const resp = await fetch(`${path}.plain.html`);
if (resp.ok) {
const main = document.createElement('main');
Expand All @@ -34,7 +36,7 @@ export async function loadFragment(path) {
resetAttributeBase('source', 'srcset');

decorateMain(main);
await loadBlocks(main);
await loadSections(main);
return main;
}
}
Expand All @@ -48,8 +50,9 @@ export default async function decorate(block) {
if (fragment) {
const fragmentSection = fragment.querySelector(':scope .section');
if (fragmentSection) {
block.closest('.section').classList.add(...fragmentSection.classList);
block.closest('.fragment').replaceWith(...fragment.childNodes);
block.classList.add(...fragmentSection.classList);
block.classList.remove('section');
block.replaceChildren(...fragmentSection.childNodes);
}
}
}
Loading

0 comments on commit f671dc6

Please sign in to comment.