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

MWPW-147219 Generate content for validator #38

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

Brandon32
Copy link
Collaborator

@Brandon32 Brandon32 commented Apr 25, 2024

  • Simple migration to add hidden block to page
  • Save markdown in source and updated folders and generate JSON for validator
  • Localize staged content directories

Resolves: MWPW-147219

* @param {string[]} locales - An array of supported locales.
* @returns {string} The staged URL.
*/
export function localizedStageUrl(siteUrl, entry, stagePath, locales = []) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there isn't a stagePath?

Suggested change
export function localizedStageUrl(siteUrl, entry, stagePath, locales = []) {
export function localizedStageUrl(siteUrl, entry, stagePath = '', locales = []) {

Or could do an early return

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string works for now, if we come up with more use cases we can decide if we want an early return.

fs.mkdirSync(outputDir, { recursive: true });
fs.writeFileSync(`${outputDir}/list.json`, JSON.stringify(config.list, null, 2));

const output = list.map((entry) => [`${siteUrl}${entry}`, localizedStageUrl(siteUrl, entry, stagePath, locales)]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better variable name might be stageOutput or stageList

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

[u('text', 'Entry'), u('text', entry)],
[u('text', 'Date'), u('text', new Date().toISOString().split('T')[0])],
];
const hideBlock = createBlock('Hide Block', fields);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little confusing to name the block with a verb. As in, is it really hiding something or is it hidden? Might be more aptly name Hidden Block if it's the latter. If this is just a test, it might not be important though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is display none in milo. I wanted to add a block like we did with card metadata but did not want it change anything visually.
https://github.com/adobecom/milo/blob/bmarshal/marketo-localized/libs/styles/styles.css#L723-L725

Comment on lines 123 to 124
const output = list.map((entry) => [`${siteUrl}${entry}`, localizedStageUrl(siteUrl, entry, stagePath, locales)]);
fs.writeFileSync(`${outputDir}/staged.json`, JSON.stringify(output, null, 2));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be optional, only if stagePath exists?

Suggested change
const output = list.map((entry) => [`${siteUrl}${entry}`, localizedStageUrl(siteUrl, entry, stagePath, locales)]);
fs.writeFileSync(`${outputDir}/staged.json`, JSON.stringify(output, null, 2));
if (stagePath) {
const output = list.map((entry) => [`${siteUrl}${entry}`, localizedStageUrl(siteUrl, entry, stagePath, locales)]);
fs.writeFileSync(`${outputDir}/staged.json`, JSON.stringify(output, null, 2));
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@JasonHowellSlavin JasonHowellSlavin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might add a README.md just to be in line with the other migration (blog-caas). Might also help clear up why you would want to add a hidden block to the page.

@Brandon32 Brandon32 merged commit 00b8606 into main Apr 26, 2024
4 checks passed
@Brandon32 Brandon32 deleted the bmarshal/markdown-for-validation branch April 26, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants