Content-Length: 251632 | pFad | http://github.com/sveltia/sveltia-cms/commit/80b0014878f5d9249107351db4378d747c44fec5

87 Enable multiple data types for default value in hidden widgets (#306) · sveltia/sveltia-cms@80b0014 · GitHub
Skip to content

Commit

Permalink
Enable multiple data types for default value in hidden widgets (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
blu3id authored Jan 14, 2025
1 parent cc0f2ef commit 80b0014
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/services/contents/widgets/hidden/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { generateUUID } from '@sveltia/utils/crypto';
* Get the default value for a Hidden field.
* @param {HiddenField} fieldConfig - Field configuration.
* @param {LocaleCode} locale - Locale code.
* @returns {string} Default value.
* @returns {any} Default value.
* @todo Write tests for this.
*/
export const getDefaultValue = (fieldConfig, locale) => {
const { default: defaultValue } = fieldConfig;

if (typeof defaultValue !== 'string') {
return '';
return defaultValue;
}

return defaultValue.replaceAll(/{{(.+?)}}/g, (_match, tag) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/typedefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@
/**
* Hidden field properties.
* @typedef {object} HiddenFieldProps
* @property {string} [default] - Default value.
* @property {any} [default] - Default value.
* @see https://decapcms.org/docs/widgets/#hidden
*/

Expand Down

0 comments on commit 80b0014

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sveltia/sveltia-cms/commit/80b0014878f5d9249107351db4378d747c44fec5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy