Skip to content

Commit

Permalink
DEV: add migration of deprecated icon names to svg_icons site setting…
Browse files Browse the repository at this point in the history
…, also rename setting to lowercase of svg_icons
  • Loading branch information
tyb-talks committed Dec 23, 2024
1 parent 5ade671 commit a422d57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
30 changes: 20 additions & 10 deletions migrations/settings/0002-migrate-from-deprecated-icon-names.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
export default function migrate(settings) {
const oldSetting = settings.get("header_links");
const oldHeaderLinksSetting = settings.get("header_links");

if (!oldSetting) {
return settings;
if (oldHeaderLinksSetting) {
const newHeaderLinksSetting = oldHeaderLinksSetting.map((link) => {
if (link.icon) {
link.icon = convertIconName(link.icon);
}
return link;
});

settings.set("header_links", newHeaderLinksSetting);
}

const newSetting = oldSetting.map((link) => {
if (link.icon) {
link.icon = convertIconName(link.icon);
}
return link;
});
const oldSvgIconsSetting = settings.get("Svg_icons");
if (oldSvgIconsSetting) {
const newSvgIconsSetting = oldSvgIconsSetting
.split("|")
.map(convertIconName)
.join("|");

settings.set("svg_icons", newSvgIconsSetting);
settings.delete("Svg_icons");
}

settings.set("header_links", newSetting);
return settings;
}

Expand Down
2 changes: 1 addition & 1 deletion settings.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_whitespace:
type: bool
default: false
Svg_icons:
svg_icons:
type: "list"
list_type: "compact"
default: "fab-facebook|fab-twitter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module(
target: "blank",
},
],
Svg_icons: "fab-facebook|fab-twitter|fab fa-cog|user-friends",
})
);

Expand Down Expand Up @@ -74,6 +75,7 @@ module(
target: "blank",
},
],
svg_icons: "fab-facebook|fab-twitter|fab-gear|user-group",
})
);

Expand Down

0 comments on commit a422d57

Please sign in to comment.