Skip to content

Commit

Permalink
Add save asset link + revamp edit link to match
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswhybrow committed Apr 19, 2024
1 parent 78a59e7 commit a555590
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
55 changes: 46 additions & 9 deletions cmd/ray-peat-rodeo/chat.templ
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,54 @@ templ RenderChat(file *File) {
</span>
</a>
</div>
<!-- Contribute to Project -->
<a
<!-- Edit / Download Asset -->
<div
data-pagefind-ignore
href={ templ.URL(file.EditPermalink) }
class="block z-10 transition-all m-2 p-4 hover:translate-y-1 shadow-lg hover:shadow-2xl shadow-green-800/20 hover:shadow-green-600/40 rounded-md bg-gradient-to-br from-green-100 from-10% to-green-100 hover:from-green-50 hover:from-70% hover:to-green-100 xl:block w-2/5 mr-[-10px] lg:mr-[-10%] xl:mr-[-20%] float-right clear-right text-sm relative leading-5 tracking-tight"
class="
block z-10 transition-all m-2 hover:translate-y-1 shadow-lg hover:shadow-2xl shadow-green-800/20 hover:shadow-green-600/40 rounded-md hover:from-green-50 hover:from-70% hover:to-green-100 w-2/5 mr-[-10px] lg:mr-[-10%] xl:mr-[-20%] float-right clear-right text-sm relative leading-5 tracking-tight overflow-hidden
"
>
<span class="text-green-700">
<img src="/assets/images/github-mark.svg" class="w-11 h-11 float-left mr-4"/>
Or, <strong>contribute</strong> to this page on GitHub.
</span>
</a>
<div class="grid grid-flow-col grid-cols-2 tracking-wider">
<a
class="
block p-4
[&:hover_span]:opacity-65 [&:hover_img]:opacity-75
bg-gradient-to-bl from-stone-200 from-10% to-stone-300
hover:bg-gradient-to-b hover:from-40% hover:from-yellow-200 hover:to-orange-300
grid grid-flow-row
transition-all
border-r border-stone-300
"
href={ templ.URL(file.EditPermalink) }
title="Edit this page on GitHub"
>
<img
src="/assets/images/edit-round-icon.svg"
alt="Edit pencil upon a black disc"
class="h-10 mx-auto opacity-50 mt-4 mb-2"
/>
<span class="uppercase text-center mb-2 text-black opacity-50 font-bold">Edit</span>
</a>
<a
class="
block p-4
[&:hover_span]:opacity-65 [&:hover_img]:opacity-75
grid grid-flow-row
bg-gradient-to-br from-stone-200 from-10% to-stone-300
hover:bg-gradient-to-br hover:from-40% hover:from-sky-200 hover:to-indigo-300
"
href={ templ.URL(file.RawPermalink) }
title="Download this page as raw Markdown"
>
<img
src="/assets/images/round-line-bottom-arrow-icon.svg"
alt="Downwards arrow within a circle"
class="h-10 mx-auto opacity-50 mt-4 mb-2 bg-clip-text bg-blue-400"
/>
<span class="uppercase text-center mb-2 text-black opacity-50 font-bold">Save</span>
</a>
</div>
</div>
if file.IsComplete() {
<!-- Attribution -->
<a
Expand Down
3 changes: 3 additions & 0 deletions cmd/ray-peat-rodeo/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type File struct {
Markdown []byte
Html []byte
EditPermalink string
RawPermalink string
Permalink string
Mentions Mentions
Mentionables ByMentionable[Mentions]
Expand Down Expand Up @@ -85,6 +86,7 @@ func NewFile(filePath string, markdownParser goldmark.Markdown, httpCache *cache
id := fileStem[11:]
permalink := "/" + id
editPermalink := global.GITHUB_LINK + path.Join("/edit/main", filePath)
rawPermalink := global.GITHUB_LINK + path.Join("/raw/main", filePath)
outPath := path.Join(OUTPUT, id, "index.html")

// 📄 FrontMatter
Expand Down Expand Up @@ -128,6 +130,7 @@ func NewFile(filePath string, markdownParser goldmark.Markdown, httpCache *cache
Date: fileStem[:10],
Permalink: permalink,
EditPermalink: editPermalink,
RawPermalink: rawPermalink,
FrontMatter: frontMatter,
Markdown: fileBytes,
Mentions: Mentions{},
Expand Down
1 change: 1 addition & 0 deletions internal/assets/images/edit-round-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions internal/assets/images/round-line-bottom-arrow-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a555590

Please sign in to comment.