diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-09 15:33:18 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-09 15:33:18 +1000 |
| commit | b26bd447354db25283f191d19904c29401c1aeaa (patch) | |
| tree | f5a11281d970f015eefa3a6401725aaf2765343d /src/modules/sidebar | |
| parent | feat: load news and calendars from cache on startup (diff) | |
| download | caelestia-shell-b26bd447354db25283f191d19904c29401c1aeaa.tar.gz caelestia-shell-b26bd447354db25283f191d19904c29401c1aeaa.tar.bz2 caelestia-shell-b26bd447354db25283f191d19904c29401c1aeaa.zip | |
news: fix news other than google news
Diffstat (limited to 'src/modules/sidebar')
| -rw-r--r-- | src/modules/sidebar/modules/headlines.tsx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/modules/sidebar/modules/headlines.tsx b/src/modules/sidebar/modules/headlines.tsx index 924e5b8..089119c 100644 --- a/src/modules/sidebar/modules/headlines.tsx +++ b/src/modules/sidebar/modules/headlines.tsx @@ -9,8 +9,6 @@ const fixGoogleNews = (colours: IPalette, title: string, desc: string) => { // Add separator, bold and split at domain (domain is at the end of each headline) const domain = title.split(" - ").at(-1); if (domain) desc = desc.replaceAll(domain, `— <span foreground="${colours.subtext0}">${domain}</span>\n\n`); - // Add spaces between sentences - desc = desc.replace(/\.([A-Z])/g, ". $1"); // Split headlines desc = desc.replace(/(( |\.)[^A-Z][a-z]+)([A-Z])/g, "$1\n\n$3"); desc = desc.replace(/( [A-Z]+)([A-Z](?![s])[a-z])/g, "$1\n\n$2"); @@ -20,6 +18,14 @@ const fixGoogleNews = (colours: IPalette, title: string, desc: string) => { return desc.trim(); }; +const fixNews = (colours: IPalette, title: string, desc: string, source: string) => { + // Add spaces between sentences + desc = desc.replace(/\.([A-Z])/g, ". $1"); + // Google News needs some other fixes + if (source === "Google News") desc = fixGoogleNews(colours, title, desc); + return desc.replaceAll("&", "&"); +}; + const getCategoryIcon = (category: string) => { if (category === "business") return "monitoring"; if (category === "crime") return "speed_camera"; @@ -81,11 +87,7 @@ const Article = ({ title, description, creator, pubDate, source_name, link }: IA useMarkup xalign={0} label={bind(Palette.get_default(), "colours").as(c => - `\n${ - source_name === "Google News" - ? fixGoogleNews(c, title, description) - : description - }`.replaceAll("&", "&") + fixNews(c, title, description, source_name) )} /> )} |