File tree Expand file tree Collapse file tree 3 files changed +79
-64
lines changed Expand file tree Collapse file tree 3 files changed +79
-64
lines changed Original file line number Diff line number Diff line change 6161 "@payloadcms/eslint-config" : " 3.28.0" ,
6262 "@semantic-release/changelog" : " ^6.0.3" ,
6363 "@semantic-release/git" : " ^10.0.1" ,
64- "@semantic-release/github" : " ^12.0.0 " ,
64+ "@semantic-release/github" : " ^12.0.1 " ,
6565 "@semantic-release/npm" : " ^13.1.1" ,
6666 "@swc/cli" : " ^0.7.8" ,
6767 "@swc/core" : " ^1.14.0" ,
6868 "@types/react" : " 19.2.2" ,
69- "eslint" : " ^9.38 .0" ,
69+ "eslint" : " ^9.39 .0" ,
7070 "payload" : " 3.62.0" ,
7171 "prettier" : " ^3.6.2" ,
7272 "rimraf" : " 6.1.0" ,
Original file line number Diff line number Diff line change @@ -158,6 +158,41 @@ export const payloadDub =
158158
159159 const attachFields = [ ...( collection . fields || [ ] ) ]
160160
161+ if ( ! attachFields . some ( ( field ) => 'name' in field && field . name === 'dubLink' ) ) {
162+ attachFields . push ( {
163+ name : 'dubLink' ,
164+ type : 'text' ,
165+ admin : {
166+ position : 'sidebar' ,
167+ readOnly : true ,
168+ } ,
169+ hooks : {
170+ afterRead : [
171+ async ( { originalDoc, req } ) => {
172+ try {
173+ if ( ! originalDoc ?. id ) {
174+ return ''
175+ }
176+
177+ const dubDoc = await req . payload . find ( {
178+ collection : 'dubLinks' ,
179+ limit : 1 ,
180+ overrideAccess : true ,
181+ where : {
182+ 'source.value' : { equals : originalDoc . id } ,
183+ } ,
184+ } )
185+
186+ return dubDoc ?. docs ?. [ 0 ] ?. shortLink || ''
187+ } catch {
188+ return ''
189+ }
190+ } ,
191+ ] ,
192+ } ,
193+ } )
194+ }
195+
161196 if ( ! attachFields . some ( ( field ) => 'name' in field && field . name === 'dubTags' ) ) {
162197 attachFields . push ( {
163198 name : 'dubTags' ,
You can’t perform that action at this time.
0 commit comments