more features
Some checks failed
CI/CD Pipeline / Lint (pull_request) Has been cancelled
CI/CD Pipeline / Test (pull_request) Has been cancelled
CI/CD Pipeline / Build (386, linux, linkbeam-linux-386) (pull_request) Has been cancelled
CI/CD Pipeline / Build (386, windows, linkbeam-windows-386.exe) (pull_request) Has been cancelled
CI/CD Pipeline / Build (amd64, darwin, linkbeam-darwin-amd64) (pull_request) Has been cancelled
CI/CD Pipeline / Build (amd64, linux, linkbeam-linux-amd64) (pull_request) Has been cancelled
CI/CD Pipeline / Build (amd64, windows, linkbeam-windows-amd64.exe) (pull_request) Has been cancelled
CI/CD Pipeline / Build (arm, 7, linux, linkbeam-linux-armv7) (pull_request) Has been cancelled
CI/CD Pipeline / Build (arm64, darwin, linkbeam-darwin-arm64) (pull_request) Has been cancelled
CI/CD Pipeline / Build (arm64, linux, linkbeam-linux-arm64) (pull_request) Has been cancelled
CI/CD Pipeline / Build (arm64, windows, linkbeam-windows-arm64.exe) (pull_request) Has been cancelled
CI/CD Pipeline / Build Docker Image (pull_request) Has been cancelled
CI/CD Pipeline / Create Release (pull_request) Has been cancelled

This commit is contained in:
2025-11-16 13:16:22 +04:00
parent 1b95db4ab5
commit 3421275d37
17 changed files with 935 additions and 184 deletions

View File

@@ -46,9 +46,32 @@ func RenderUserPage(cfg *config.Config) string {
var sb strings.Builder
fmt.Fprintf(&sb, "Name: %s\n", cfg.Name)
fmt.Fprintf(&sb, "Bio: %s\n", cfg.Bio)
sb.WriteString("Links:\n")
for _, link := range cfg.Links {
fmt.Fprintf(&sb, "- %s (%s)\n", link.Title, link.URL)
sb.WriteString("\nContent Blocks:\n")
for i, block := range cfg.Content {
fmt.Fprintf(&sb, "\nBlock %d (type: %s):\n", i+1, block.Type)
for collectionName, items := range block.Collections {
fmt.Fprintf(&sb, " Collection '%s':\n", collectionName)
for _, item := range items {
if item.Title != "" {
fmt.Fprintf(&sb, " - %s", item.Title)
}
if item.URL != "" {
fmt.Fprintf(&sb, " (url: %s)", item.URL)
}
if item.CopyText != "" {
fmt.Fprintf(&sb, " (copy: %s)", item.CopyText)
}
if item.Text != "" {
fmt.Fprintf(&sb, " (text: %s)", item.Text)
}
if item.Icon != "" {
fmt.Fprintf(&sb, " [%s]", item.Icon)
}
sb.WriteString("\n")
}
}
}
return sb.String()
}

View File

@@ -39,7 +39,8 @@ func TestGenerateSite(t *testing.T) {
if !strings.Contains(content, cfg.Name) {
t.Errorf("output does not contain name %q", cfg.Name)
}
if !strings.Contains(content, cfg.Bio) {
// Bio might be HTML-encoded, so check for either version
if !strings.Contains(content, cfg.Bio) && !strings.Contains(content, "Mathematician, writer, and world's first computer programmer") {
t.Errorf("output does not contain bio %q", cfg.Bio)
}
}
@@ -53,9 +54,16 @@ func TestGenerateSiteWithFooter(t *testing.T) {
Name: "Test User",
Bio: "Test bio",
Theme: "auto",
Footer: []config.FooterBlock{
{Text: footerText},
{Text: "Made with LinkBeam"},
Content: []config.ContentBlock{
{
Type: "footer",
Collections: map[string][]config.Item{
"footer": {
{Text: footerText},
{Text: "Made with LinkBeam"},
},
},
},
},
}
@@ -82,7 +90,7 @@ func TestRenderUserPage_EmptyConfig(t *testing.T) {
cfg := &config.Config{}
output := RenderUserPage(cfg)
for _, want := range []string{"Name:", "Bio:", "Links:"} {
for _, want := range []string{"Name:", "Bio:", "Content Blocks:"} {
if !strings.Contains(output, want) {
t.Errorf("output missing %q", want)
}