Skip to content

Commit

Permalink
Make sure only values under 20 can be used for the orderHint frontm…
Browse files Browse the repository at this point in the history
…atter (#2039)

* chore: update orderHint logic

* chore: add changeset

* chore: optimize docs
  • Loading branch information
timonrey authored Jul 24, 2024
1 parent 660c19d commit d1cdc2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-plants-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-docs/gatsby-theme-docs': patch
---

Ensure that the orderHint release note frontmatter can only be set to 20 or lower.
11 changes: 6 additions & 5 deletions packages/gatsby-theme-docs/gatsby-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,12 @@ const config = (themeOptions = {}) => {
return allReleaseNotePage.nodes.map((node) => {
// We add the orderHint frontmatter as hours to the release date to have
// better control over the release note order.
const dateWithTime = node.orderHint
? new Date(
new Date(node.date).setHours(20 - node.orderHint)
)
: new Date(node.date);
const dateWithTime =
node.orderHint && node.orderHint <= 20
? new Date(
new Date(node.date).setHours(20 - node.orderHint)
)
: new Date(node.date);
return {
...node,
url: `${site.siteMetadata.siteUrl}${node.slug}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If there is no more, remove the marker above, too.
- `description` (string, required): Max 256 characters plain text containing the change and its advantage ("tweet-able" and for RSS).
256 = 280 twitter minus 23 for a link. Do not imply the title, this text is used stand-alone in Merchant Center and other feed recipients. It must convey the value proposition and key change topic.
- `type` (string | string[], required): Must be either `feature` (for "New feature"), `enhancement` (for "Enhancement"), `fix` (for "Resolved issue"), `announcement` (for "Announcement") or `deprecation` (for "Deprecation").
- `orderHint` (number, optional): Sorts release notes that share the same release date. Uses an ascending order with 1 being the most recent release note and 20 being the oldest. This logic works across multiple microsites. If you have multiple release notes from different microsites with the same release date, add this frontmatter to the respective release notes to sort them accordingly from 1 to 20.
- `orderHint` (number, optional): Sorts release notes that share the same release date by adjusting the timestamp. Uses an ascending order with 1 being the most recent release note and 20 being the oldest. This logic works across multiple microsites. If you have multiple release notes from different microsites with the same release date, add this frontmatter to the respective release notes to sort them accordingly from 1 to 20. Values above 20 will be ignored.
- `topics` (array of string, optional): YAML array of free to choose text entries. The Filter UI may be constrained to pre-defined topics.
- `published` (boolean, optional, defaults to `true`): `false` prevents rendering of the release in the site. **Should not be used in the main documentation**, reserved for atypical situations. Not included in the template.
- `slug` (string, optional, defaults to `$date-$title` (slugified)): Allows overriding the autogenerated URL slug. **Should not be used in the main documentation**, reserved for migrating legacy docs.
Expand Down

0 comments on commit d1cdc2f

Please sign in to comment.