Skip to content

Commit

Permalink
Automatically update try links on release pages
Browse files Browse the repository at this point in the history
Direct download for current and future releases, link to try page for older releases
  • Loading branch information
lukasbestle committed Jan 4, 2025
1 parent b414b11 commit ebc8d33
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 0 additions & 2 deletions content/releases/3-10/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Version: 3.10
----
ogimage: opengraph.png
----
Link: https://github.com/getkirby/kirby/releases/tag/3.10.0
----
Cover: - kirby-3-10.png
----

Expand Down
2 changes: 0 additions & 2 deletions content/releases/3-6/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Description: Improvements all over: New way to present your content, an improved
----
Cover: kirby-3-6.png
----
Link: https://github.com/getkirby/kirby/releases/tag/3.6.0
----
Area:

```php
Expand Down
2 changes: 0 additions & 2 deletions content/releases/3-7/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Version: 3.7
----
ogimage: opengraph.png
----
Link: https://github.com/getkirby/kirby/releases/tag/3.7.0
----
Description: The Panel is in the focus of this new release with a fresh look, a stats section that turns your dashboard into a smart report, a new table layout, and a new system view that gives you an overview about everything regarding your installation.

----
Expand Down
2 changes: 0 additions & 2 deletions content/releases/3-8/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Version: 3.8
----
ogimage: opengraph.png
----
Link: https://github.com/getkirby/kirby/releases/tag/3.8.0
----
Cover: - kirby-3-8.png
----
Description: Lost relations are a thing of the past with the new UUID and permalink features for pages, files and users.
Expand Down
2 changes: 0 additions & 2 deletions content/releases/3-9/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Version: 3.9
----
ogimage: opengraph.png
----
Link: https://github.com/getkirby/kirby/releases/tag/3.9.0
----
Cover: - kirby-3-9.png
----

Expand Down
4 changes: 1 addition & 3 deletions content/releases/4/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ Description: Kirby 4 is all about a new editing experience for users, with a bra
----
Docs: /docs
----
Cover: - kirby-4-0.png
----
Link: https://github.com/getkirby/kirby/archive/refs/tags/4.3.1.zip
Cover: - kirby-4-0.png
4 changes: 1 addition & 3 deletions content/releases/5/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ Description: Kirby 5 is taking existing features to new levels: collaborate on c
----
Docs: /releases/5/changes
----
Cover: - kirby-5-0.png
----
Link: https://github.com/getkirby/kirby/archive/refs/tags/5.0.0-beta.1.zip
Cover: - kirby-5-0.png
14 changes: 14 additions & 0 deletions site/models/release.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Kirby\Content\Field;
use Kirby\Github\Github;
use Kirby\Template\Template;
use Kirby\Toolkit\Str;
Expand Down Expand Up @@ -97,6 +98,19 @@ public function template(): Template
return $this->template ??= $this->kirby()->template($template);
}

public function tryLink(): Field
{
$field = parent::tryLink();

// never link to downloads of previous major releases
if (Str::before($this->kirby()->version(), '.') > $this->version()) {
return $field;
}

$url = 'https://github.com/getkirby/kirby/archive/refs/tags/' . $this->latestRelease() . '.zip';
return $field->or($url);
}

public function url($options = null): string
{
return $this->parent()->url() . '/' . str_replace('-', '.', $this->slug());
Expand Down
2 changes: 1 addition & 1 deletion site/snippets/templates/releases/cta.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
[
'text' => 'Try now',
'link' => $page->link(),
'link' => $page->tryLink()->or('/try'),
'icon' => 'download'
],
],
Expand Down

0 comments on commit ebc8d33

Please sign in to comment.