diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 8c7cc935..7670c223 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -36,29 +36,28 @@ type Pages struct { t map[string]*template.Template } - - func NewPages() *Pages { templates := make(map[string]*template.Template) - fragmentPaths := []string{} + var fragmentPaths []string // First, collect all fragment paths err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error { if err != nil { return err } - if !d.IsDir() && strings.HasSuffix(path, ".html") && strings.Contains(path, "fragments/") { - fragmentPaths = append(fragmentPaths, path) + if d.IsDir() { + return nil + } + + if !strings.HasSuffix(path, ".html") { + return nil + } + + if !strings.Contains(path, "fragments/") { + return nil } - return nil - }) - if err != nil { - log.Fatalf("walking template dir for fragments: %v", err) - } - // Load all fragments first - for _, path := range fragmentPaths { name := strings.TrimPrefix(path, "templates/") name = strings.TrimSuffix(name, ".html") @@ -70,7 +69,12 @@ func NewPages() *Pages { } templates[name] = tmpl + fragmentPaths = append(fragmentPaths, path) log.Printf("loaded fragment: %s", name) + return nil + }) + if err != nil { + log.Fatalf("walking template dir for fragments: %v", err) } // Then walk through and setup the rest of the templates @@ -79,29 +83,41 @@ func NewPages() *Pages { return err } - if !d.IsDir() && strings.HasSuffix(path, ".html") { - name := strings.TrimPrefix(path, "templates/") - name = strings.TrimSuffix(name, ".html") - - // Skip fragments as they've already been loaded - if strings.Contains(path, "fragments/") { - return nil - } - - // Load layouts and main templates - if !strings.HasPrefix(path, "templates/layouts/") { - // Add the page template on top of the base - tmpl, err := template.New(name). - Funcs(funcMap()). - ParseFS(Files, "templates/layouts/*.html", "templates/**/fragments/*.html", path) - if err != nil { - return fmt.Errorf("setting up template: %w", err) - } - - templates[name] = tmpl - log.Printf("loaded template: %s", name) - } + if d.IsDir() { + return nil } + + if !strings.HasSuffix(path, "html") { + return nil + } + + // Skip fragments as they've already been loaded + if strings.Contains(path, "fragments/") { + return nil + } + + // Skip layouts + if strings.Contains(path, "layouts/") { + return nil + } + + name := strings.TrimPrefix(path, "templates/") + name = strings.TrimSuffix(name, ".html") + + // Add the page template on top of the base + allPaths := []string{} + allPaths = append(allPaths, "templates/layouts/*.html") + allPaths = append(allPaths, fragmentPaths...) + allPaths = append(allPaths, path) + tmpl, err := template.New(name). + Funcs(funcMap()). + ParseFS(Files, allPaths...) + if err != nil { + return fmt.Errorf("setting up template: %w", err) + } + + templates[name] = tmpl + log.Printf("loaded template: %s", name) return nil }) if err != nil { diff --git a/appview/pages/templates/repo/index.html b/appview/pages/templates/repo/index.html index c54b3c46..c6705b9b 100644 --- a/appview/pages/templates/repo/index.html +++ b/appview/pages/templates/repo/index.html @@ -176,9 +176,7 @@ {{ slice .Hash.String 0 8 }} - + >{{ slice .Hash.String 0 8 }} diff --git a/appview/pages/templates/repo/issues/fragments/issueComment.html b/appview/pages/templates/repo/issues/fragments/issueComment.html index 9d064798..2f04a453 100644 --- a/appview/pages/templates/repo/issues/fragments/issueComment.html +++ b/appview/pages/templates/repo/issues/fragments/issueComment.html @@ -1,14 +1,14 @@ {{ define "repo/issues/fragments/issueComment" }} {{ with .Comment }}
-
+
{{ $owner := index $.DidHandleMap .OwnerDid }} {{ $owner }} {{ if .Deleted }} deleted {{ .Deleted | timeFmt }} diff --git a/tailwind.config.js b/tailwind.config.js index d132a5eb..32eba019 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -2,49 +2,62 @@ const colors = require("tailwindcss/colors"); module.exports = { - content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"], - darkMode: "media", - theme: { - container: { - padding: "2rem", - center: true, - screens: { - sm: "500px", - md: "600px", - lg: "800px", - xl: "1000px", - "2xl": "1200px", - }, - }, - extend: { - fontFamily: { - sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"], - mono: [ - "IBMPlexMono", - "ui-monospace", - "SFMono-Regular", - "Menlo", - "Monaco", - "Consolas", - "Liberation Mono", - "Courier New", - "monospace", - ], - }, - typography: { - DEFAULT: { - css: { - maxWidth: "none", - pre: { - backgroundColor: colors.gray[100], - color: colors.black, - "@apply dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border": - {}, - }, - }, - }, - }, - }, - }, - plugins: [require("@tailwindcss/typography")], + content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"], + darkMode: "media", + theme: { + container: { + padding: "2rem", + center: true, + screens: { + sm: "500px", + md: "600px", + lg: "800px", + xl: "1000px", + "2xl": "1200px", + }, + }, + extend: { + fontFamily: { + sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"], + mono: [ + "IBMPlexMono", + "ui-monospace", + "SFMono-Regular", + "Menlo", + "Monaco", + "Consolas", + "Liberation Mono", + "Courier New", + "monospace", + ], + }, + typography: { + DEFAULT: { + css: { + maxWidth: "none", + pre: { + backgroundColor: colors.gray[100], + color: colors.black, + "@apply font-normal text-black bg-gray-100 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border": {}, + }, + code: { + "@apply font-normal font-mono p-1 rounded text-black bg-gray-100 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700": {}, + }, + "code::before": { + content: '""', + "padding-left": "0.25rem" + }, + "code::after": { + content: '""', + "padding-right": "0.25rem" + }, + blockquote: { + quotes: "none", + }, + }, + }, + }, + }, + }, + plugins: [require("@tailwindcss/typography")], };