Skip to content

feat: new custompages upload command #1265

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

Merged
merged 19 commits into from
Jun 25, 2025

Conversation

emilyskuo
Copy link
Member

@emilyskuo emilyskuo commented Jun 18, 2025

🚥 Resolves RM-12966

🧰 Changes

Adding a new custompages upload command for folks to upload MD or HTML custom pages. Largely copied from docs/reference upload with some minor tweaks (adding HTML as a valid input).

🧬 QA & Testing

See __tests__/commands/custompages/upload.test.ts. Also did some manual testing locally with some of the custom page test fixtures

@emilyskuo emilyskuo marked this pull request as ready for review June 24, 2025 00:18
@emilyskuo emilyskuo requested a review from kanadgupta as a code owner June 24, 2025 00:18
@emilyskuo emilyskuo requested a review from erunion June 24, 2025 00:19
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

a couple small nits below but overall this looks great! quick question since the answer is not immediately jumping out to me — if a user passes an HTML file into this, do we set the type: 'html'?

Copy link
Member

@erunion erunion left a comment

Choose a reason for hiding this comment

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

+1'ing kanad's feedback but this lgtm

@emilyskuo
Copy link
Member Author

emilyskuo commented Jun 24, 2025

quick question since the answer is not immediately jumping out to me — if a user passes an HTML file into this, do we set the type: 'html'?

@kanadgupta I tested this out with an HTML file with just a title in the metadata and no we're not 😬 It uploaded as type: 'markdown' (I assume as a default). AJV doesn't catch it as an error, but we could add a check to fix to update content.type if it detects an html file

Screenshot 2025-06-24 at 11 50 58 AM

@kanadgupta
Copy link
Member

kanadgupta commented Jun 24, 2025

@emilyskuo hmm yeah there are a few places we could do this... i wouldn't necessarily consider this a "frontmatter fix" per se since this shouldn't be an attribute that users specify in their frontmatter — what if we did it around here instead:

// normalize the category uri
if (payload.category?.uri) {
const regex = new RegExp(categoryUriRegexPattern);
if (!regex.test(payload.category.uri)) {
let uri = payload.category.uri;
this.debug(`normalizing category uri ${uri} for ${filePath}`);
// remove leading and trailing slashes
uri = uri.replace(/^\/|\/$/g, '');
payload.category.uri = `/branches/${branch}/categories/${this.route}/${uri}`;
}
}
// normalize the parent uri
if (payload.parent?.uri) {
const regex = new RegExp(parentUriRegexPattern);
if (!regex.test(payload.parent.uri)) {
let uri = payload.parent.uri;
this.debug(`normalizing parent uri ${uri} for ${filePath}`);
// remove leading and trailing slashes
uri = uri.replace(/^\/|\/$/g, '');
payload.parent.uri = `/branches/${branch}/${this.route}/${uri}`;
}
}

in those if-statements, we're patching the category/parent page data in the payload prior to hitting the API, so maybe that's also a good spot to do this as well? i believe this pushPage function should have access to all the info you need (the full file name, the fixed up frontmatter data, etc.). if you look at my very much in-progress changelog PR, i also enhanced the types of those payloads to support changelog types. if you end up running with this approach i'd probably suggest doing that as well.

let me know if you think of a better spot or if you run into any issues with this approach!

@kanadgupta kanadgupta added the command:pages Issues pertaining to page upload commands (e.g., `docs`, `reference`, `changelog`, `custompages`) label Jun 24, 2025
@emilyskuo emilyskuo requested a review from kanadgupta June 25, 2025 18:06
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

just a handful of requested changes that should be quick to address, but on the whole this looks phenomenal. great work ❤️‍🔥

@emilyskuo emilyskuo requested a review from kanadgupta June 25, 2025 18:32
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

hell yeah brother 🤘🏽 this was a surprisingly gnarly change, awesome work!

@kanadgupta kanadgupta merged commit dc4ceb4 into next Jun 25, 2025
8 checks passed
@kanadgupta kanadgupta deleted the emily/rm-12966-rdme-custompages-upload branch June 25, 2025 18:47
kanadgupta pushed a commit that referenced this pull request Jun 25, 2025
# [10.4.0-next.1](v10.3.0...v10.4.0-next.1) (2025-06-25)

### Features

* new `custompages upload` command ([#1265](#1265)) ([dc4ceb4](dc4ceb4))

[skip ci]
@kanadgupta
Copy link
Member

🎉 This PR is included in version 10.4.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:pages Issues pertaining to page upload commands (e.g., `docs`, `reference`, `changelog`, `custompages`) released on @next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants