-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Puck and Drupal configuration
- Loading branch information
1 parent
e7dbc68
commit 3a62b55
Showing
20 changed files
with
281 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
...d-packages/@powerstack/utils/src/Utils.js → frontend/packages/utils/src/Utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 42 additions & 11 deletions
53
frontend/starters/development/components/drupal/BasicPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,55 @@ | ||
"use client" | ||
|
||
import type { DrupalNode } from "next-drupal" | ||
import config from "../../puck.config"; | ||
import { Render } from "@measured/puck"; | ||
import { capitalize, formatDrupalType, formatDrupalField, drupalFieldPrefix } from "@powerstack/utils" | ||
|
||
|
||
interface BasicPageProps { | ||
node: DrupalNode | ||
} | ||
|
||
export function BasicPage({ node, ...props }: BasicPageProps) { | ||
console.log(node) | ||
|
||
function extractFieldKeys(data) { | ||
const result = {}; | ||
for (const key in data) { | ||
if (data.hasOwnProperty(key) && key.startsWith(drupalFieldPrefix)) { | ||
const newKey = formatDrupalField(key); // Remove 'field_' prefix | ||
const fieldData = data[key].hasOwnProperty('value') ? data[key].value : data[key] | ||
result[newKey] = fieldData; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
const content = node?.field_page_builder.map((block) => { | ||
|
||
const type = capitalize(formatDrupalType(block.type)); | ||
if (type === 'Hero' || 'Text') { | ||
|
||
console.log(extractFieldKeys(block)) | ||
return { | ||
type: type, | ||
id: `${type}-${block.id}`, | ||
props: extractFieldKeys(block) | ||
} | ||
} | ||
} | ||
|
||
) | ||
|
||
const data = { | ||
root: { | ||
props: { | ||
title: node.title | ||
} | ||
}, | ||
content: content | ||
} | ||
|
||
return ( | ||
<article {...props}> | ||
<h1 className="mb-4 text-6xl font-black leading-tight">{node.title}</h1> | ||
|
||
{node?.field_page_builder[0]?.field_section_fields[0].field_column_fields[0].field_text.processed && ( | ||
<div | ||
dangerouslySetInnerHTML={{ __html: node?.field_page_builder[0].field_section_fields[0].field_column_fields[0].field_text.processed}} | ||
className="mt-6 font-serif text-xl leading-loose prose" | ||
/> | ||
)} | ||
</article> | ||
<Render config={config} data={data} /> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,70 @@ | ||
{"/":{"content":[{"type":"Hero","props":{"title":"Power Stack","id":"Hero-a8a69850-d5dc-4cf0-8348-15142671a427","subtitle":"Supercharging digital experiences for the modern web.","description":"Build more reliable software with AI companion. AI is also trained to detect lazy developers who do nothing and just complain on Twitter."}},{"type":"Text","props":{"title":"Brilliance is upon us","id":"Text-9abe7f09-4665-462e-935e-2f8cc48665ad","text":"This is sooo good."}},{"type":"Stats","props":{"title":"Heading","id":"Stats-05ac6b81-dcfa-4ebc-9c39-f9d96faa63fa","stats":[{"title":"Page views","subtitle":"test","description":"24% more than in the same month last year, 33% more that two years ago","stats":"456,133"},{"title":"New users","stats":"2,175","description":"13% less compared to last month, new user engagement up by 6%"},{"title":"Completed orders","stats":"1,994","description":"1994 orders were completed this month, 97% satisfaction rate"}]}},{"type":"Text","props":{"title":"Never looking back","id":"Text-0267de45-a97d-45b4-a861-dc50b430bd4e","text":"Good tech stands the test of time"}},{"type":"Text","props":{"title":"Simple. Beautiful. Easy.","id":"Text-b52062cb-fc95-4877-8e33-82d013611ec7","text":"How all editing experiences should be"}}],"root":{"props":{"title":"Home"}},"zones":{}}} | ||
{ | ||
"/": { | ||
"content": [ | ||
{ | ||
"type": "Hero", | ||
"props": { | ||
"title": "Power Stack", | ||
"id": "Hero-a8a69850-d5dc-4cf0-8348-15142671a427", | ||
"subtitle": "Supercharging digital experiences for the modern web.", | ||
"description": "Build more reliable software with AI companion. AI is also trained to detect lazy developers who do nothing and just complain on Twitter." | ||
} | ||
}, | ||
{ | ||
"type": "Text", | ||
"props": { | ||
"title": "Brilliance is upon us", | ||
"id": "Text-9abe7f09-4665-462e-935e-2f8cc48665ad", | ||
"text": "This is sooo good." | ||
} | ||
}, | ||
{ | ||
"type": "Stats", | ||
"props": { | ||
"title": "Heading", | ||
"id": "Stats-05ac6b81-dcfa-4ebc-9c39-f9d96faa63fa", | ||
"stats": [ | ||
{ | ||
"title": "Page views", | ||
"subtitle": "test", | ||
"description": "24% more than in the same month last year, 33% more that two years ago", | ||
"stats": "456,133" | ||
}, | ||
{ | ||
"title": "New users", | ||
"stats": "2,175", | ||
"description": "13% less compared to last month, new user engagement up by 6%" | ||
}, | ||
{ | ||
"title": "Completed orders", | ||
"stats": "1,994", | ||
"description": "1994 orders were completed this month, 97% satisfaction rate" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "Text", | ||
"props": { | ||
"title": "Never looking back", | ||
"id": "Text-0267de45-a97d-45b4-a861-dc50b430bd4e", | ||
"text": "Good tech stands the test of time" | ||
} | ||
}, | ||
{ | ||
"type": "Text", | ||
"props": { | ||
"title": "Simple. Beautiful. Easy.", | ||
"id": "Text-b52062cb-fc95-4877-8e33-82d013611ec7", | ||
"text": "How all editing experiences should be" | ||
} | ||
} | ||
], | ||
"root": { | ||
"props": { | ||
"title": "Home" | ||
} | ||
}, | ||
"zones": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.