bastibe / org-static-blog

A static site generator using org-mode
BSD 3-Clause "New" or "Revised" License
341 stars 74 forks source link

Show only post titles in multipost pages (no preview, no contents) #124

Open protesilaos opened 11 months ago

protesilaos commented 11 months ago

Hello @bastibe and thank you for this package!

I have noticed that when setting org-static-blog-use-preview to nil, the produced archive page includes the complete file contents. The code for that is in org-static-blog-assemble-multipost-page:

    (apply 'concat (mapcar
                    (if org-static-blog-use-preview
                        'org-static-blog-get-preview
                      'org-static-blog-get-post-content)
                    post-filenames))

Do you think we can make this behaviour configurable? The idea is to only display titles without any further contents.

bastibe commented 11 months ago

Hi @protesilaos,

are you sure about the archive? The index should include full posts or previews, but the archive should only include headlines.

protesilaos commented 11 months ago

From: Bastian Bechtold @.***> Date: Sun, 10 Dec 2023 07:48:05 -0800

Hi @protesilaos,

are you sure about the archive? The index should include full posts or previews, but the archive should only include headlines.

Oh, sorry! I was meaning for the index. Can we have only headlines there?

-- Protesilaos Stavrou https://protesilaos.com

bastibe commented 11 months ago

I see. If you'd like to contribute a mechanism for a headline-only index, I'd be happy to review it.

lemyx commented 11 months ago

I have met the similar situation, my workaround is to cover the configuration outside the pulled repository.

(defun org-static-blog-get-preview (post-filename)
  "Get title, date, tags from POST-FILENAME and get the first paragraph from the rendered HTML.
If the HTML body contains multiple paragraphs, include only the first paragraph,
and display an ellipsis.
Preamble and Postamble are excluded, too."
  (with-temp-buffer
    (insert-file-contents (org-static-blog-matching-publish-filename post-filename))
    (let ((post-title (org-static-blog-get-title post-filename))
          (post-date (org-static-blog-get-date post-filename))
          (preview-region (org-static-blog--preview-region)))
      ;; Put the substrings together.
      (let ((title-link
             (format "<h2 class=\"post-title\"><a href=\"%s\">%s</a></h2>"
                     (org-static-blog-get-post-url post-filename) post-title))
            (date-link
             (format-time-string (concat "<div class=\"post-date\">"
                                         (org-static-blog-gettext 'date-format)
                                         "</div>")
                                 post-date)))
        (concat
         title-link
         preview-region
         date-link
         )))))

By doing so, only title, preview and date are displayed.