Add education resource ggcode stuff!

This commit is contained in:
Ben Visness 2022-09-10 09:54:19 -05:00
parent 9e353c715f
commit 9ffc64fcf3
6 changed files with 12 additions and 6 deletions

Binary file not shown.

View File

@ -1176,7 +1176,7 @@ img, video {
.br2, .post-content code, .post-content pre > code, .post-content pre.hmn-code {
border-radius: 0.25rem; }
.br3 {
.br3, .edu-resource {
border-radius: 0.5rem; }
.br4 {
@ -4602,7 +4602,7 @@ code, .code {
.pa2, .tab, header .root-item > a, header .submenu > a {
padding: 0.5rem; }
.pa3, header #login-popup {
.pa3, .edu-resource, header #login-popup {
padding: 1rem; }
.pa4 {
@ -7426,7 +7426,7 @@ article code {
border-color: #ccc;
border-color: var(--theme-color-dimmest); }
.bg--dim, .post-content code, .post-content pre > code, .post-content pre.hmn-code {
.bg--dim, .post-content code, .post-content pre > code, .post-content pre.hmn-code, .edu-resource {
background-color: #f0f0f0;
background-color: var(--dim-background); }

View File

@ -6,6 +6,7 @@ import (
"regexp"
"git.handmade.network/hmn/hmn/src/hmnurl"
"git.handmade.network/hmn/hmn/src/utils"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/ast"
gast "github.com/yuin/goldmark/ast"
@ -55,9 +56,10 @@ var ggcodeTags = map[string]ggcodeRenderer{
},
"resource": func(w util.BufWriter, n *ggcodeNode, entering bool) error {
if entering {
w.WriteString("a node :o")
w.WriteString(`<div class="edu-resource">`)
w.WriteString(fmt.Sprintf(` <a href="%s" target="_blank"><h2>%s</h2></a>`, n.Args["url"], utils.OrDefault(n.Args["name"], "[missing `name`]")))
} else {
w.WriteString("bai")
w.WriteString("</div>")
}
return nil
},

View File

@ -0,0 +1,3 @@
.edu-resource {
@extend .pa3, .bg--dim, .br3;
}

View File

@ -12,6 +12,7 @@
@import 'content';
@import 'editor';
@import 'episodes';
@import 'education';
@import 'forms';
@import 'forum';
@import 'header';

View File

@ -2,7 +2,7 @@
{{ define "content" }}
<h1>{{ .Title }}</h1>
{{ if .User.IsEduAuthor }}
{{ if and .User .User.IsEduAuthor }}
<div class="mb3">
<a href="{{ .EditUrl }}" title="Edit">&#9998; Edit</a>
<a href="{{ .DeleteUrl }}" title="Delete">&#10006; Delete</a>