sanity-plugin-recurring-dates 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -9
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +269 -244
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +269 -244
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/components/CustomRule/Monthly.tsx +1 -1
- package/src/plugin.tsx +1 -1
- package/src/types.ts +6 -0
package/README.md
CHANGED
|
@@ -135,13 +135,16 @@ import {formatInTimeZone, getTimezoneOffset} from 'date-fns-tz'
|
|
|
135
135
|
// your desired timezone
|
|
136
136
|
const timezone = 'Europe/London'
|
|
137
137
|
|
|
138
|
+
// Start date as a date
|
|
139
|
+
const startDate = new Date(recurringDate.startDate)
|
|
140
|
+
|
|
138
141
|
// Pass your rrule and startDate to the `rrulestr` function
|
|
139
|
-
const upcomingRule = rrulestr(rrule, {
|
|
142
|
+
const upcomingRule = rrulestr(recurringDate.rrule, {
|
|
140
143
|
dtstart: startDate,
|
|
141
144
|
})
|
|
142
145
|
|
|
143
146
|
// Calculate the offset from UTC for your timezone at the start date
|
|
144
|
-
const initialOffset = getTimezoneOffset(timezone,
|
|
147
|
+
const initialOffset = getTimezoneOffset(timezone, startDate)
|
|
145
148
|
|
|
146
149
|
// Map through all the rules, returning an array of dates in the correct timezone
|
|
147
150
|
// with consideration for changes in timezone offset as a result of DST
|
|
@@ -157,11 +160,7 @@ const allDates = rule.all().map((date) => {
|
|
|
157
160
|
|
|
158
161
|
// Return a formatted date from the date needed, with the format we pass
|
|
159
162
|
// in the third parameter
|
|
160
|
-
return formatInTimeZone(
|
|
161
|
-
date.setTime(date.getTime() + diff),
|
|
162
|
-
timezone,
|
|
163
|
-
'EEEE, MMMM d, yyyy h:mm aaaa',
|
|
164
|
-
)
|
|
163
|
+
return formatInTimeZone(date, timezone, 'EEEE, MMMM d, yyyy h:mm aaaa')
|
|
165
164
|
})
|
|
166
165
|
```
|
|
167
166
|
|
|
@@ -177,10 +176,9 @@ with default configuration for build & watch scripts.
|
|
|
177
176
|
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
178
177
|
on how to run this plugin with hotreload in the studio.
|
|
179
178
|
|
|
180
|
-
|
|
181
179
|
### Release new version
|
|
182
180
|
|
|
183
181
|
Run ["CI & Release" workflow](https://github.com/thebiggianthead/sanity-plugin-recurring-dates/actions/workflows/main.yml).
|
|
184
182
|
Make sure to select the main branch and check "Release new version".
|
|
185
183
|
|
|
186
|
-
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
|
184
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
package/dist/index.d.ts
CHANGED
|
@@ -9,12 +9,18 @@ export declare interface PluginConfig {
|
|
|
9
9
|
dateTimeOptions?: DatetimeOptions
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export declare interface RecurringDate {
|
|
13
|
+
rrule: string
|
|
14
|
+
startDate: string
|
|
15
|
+
endDate: String
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export declare type RecurringDateFieldOptions = Omit<ObjectDefinition, 'type' | 'fields'> & {
|
|
13
19
|
type: 'recurringDates'
|
|
14
20
|
options?: PluginConfig
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
export declare const recurringDates: Plugin_2<PluginConfig>
|
|
23
|
+
export declare const recurringDates: Plugin_2<void | PluginConfig>
|
|
18
24
|
|
|
19
25
|
export declare type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
|
|
20
26
|
[Property in Key]-?: Type[Property]
|