Giter Site home page Giter Site logo

Change URL patterns about org-static-blog HOT 5 CLOSED

bastibe avatar bastibe commented on July 20, 2024
Change URL patterns

from org-static-blog.

Comments (5)

bastibe avatar bastibe commented on July 20, 2024 1

Cool! I love how malleable Emacs is!

If anyone is interested in this feature, feel free to re-open the issue!

from org-static-blog.

bastibe avatar bastibe commented on July 20, 2024

I am not sure I understand your questions completely. Please correct me if I'm misinterpreting something.

org-static-blog takes a bunch of org files in a posts directory, and renders them as HTML in the main directory. In addition, it assembles an index.html, an archive.html, an RSS feed, a tags.html, and one HTML page per tag.

Each file in posts has a date, and optionally a number of tags. For example, one of my recent blog posts started with

#+title: How to Write a Dissertation
#+date: <2020-05-27 18:11>
#+filetags: computers emacs workflow

(I realize that I should put an example like this in the README. I'll do that right away.)

Does this answer your questions?

from org-static-blog.

aciceri avatar aciceri commented on July 20, 2024

Sorry if I wasn't clear, I meant that I don't like to have all the html pages in the main directory, I would prefer to the posts and the tags pages in dedicated folders.
It's a matter of personal tastes, but I would prefer that my urls would be something like this:

In this way, evey generated html page need to be called index.html and be placed inside a specific folder.

I was able to get a similar behaviour using only org, I can try to get something similar with org-static-blog.
What do you think?

from org-static-blog.

bastibe avatar bastibe commented on July 20, 2024

I think this is possible. There are customizable variables for pretty much every file name and directory. You might need to have "file names" such as "archive/archive.html" and create the enclosing "archive" by hand, but apart from that it should all work.

from org-static-blog.

aciceri avatar aciceri commented on July 20, 2024

I managed to get my goal, I simply added to my publish script the following lines:

(setq org-static-blog-tags-file "tag/index.html"
      org-static-blog-archive-file "archive/index.html"
      org-static-blog-rss-file "rss/index.rss")

(advice-add 'org-static-blog-generate-post-path
	    :around #'(lambda (orig-fun &rest args)
  (let* ((filename (car args))
	 (new-filename (concat "post/"
			       (file-name-sans-extension filename)
			       "/index.html")))
    (apply orig-fun (cons new-filename (cdr args))))))

(defun org-static-blog-assemble-tags ()
  (org-static-blog-assemble-tags-archive)
  (dolist (tag (org-static-blog-get-tag-tree))
    (org-static-blog-assemble-multipost-page
     (concat org-static-blog-publish-directory "tag/" (downcase (car tag)) "/index.html")
     (cdr tag)
     (concat "<h1 class=\"title\">" (org-static-blog-gettext 'posts-tagged) " \"" (car tag) "\":</h1>"))))

(defun org-static-blog-post-taglist (post-filename)
  (let ((taglist-content ""))
    (when (and (org-static-blog-get-tags post-filename) org-static-blog-enable-tags)
      (setq taglist-content (concat "<a href=\""
                                    (org-static-blog-get-absolute-url org-static-blog-tags-file)
                                    "\">" (org-static-blog-gettext 'tags) "</a>: "))
      (dolist (tag (org-static-blog-get-tags post-filename))
        (setq taglist-content (concat taglist-content "<a href=\""
                                      (org-static-blog-get-absolute-url (concat "tag/" (downcase tag) "/"))
                                      "\">" tag "</a> "))))
    taglist-content))

(advice-add 'org-static-blog-get-post-url
	    :around #'(lambda (orig-fun &rest args)
			(file-name-directory (apply orig-fun args))))

I set three variables, adviced and overwrote some functions.
This approach seems to work, all the internal links work. Maybe is not so elegant and I don't think it can be easily integrated.
I noticed that some links are extended e.g. /archive/index.html instead of simply /archive/ but at least for posts and tags I solved this problem.
Solving this would require the overwriting of other functions (pretty long) and since it's not so important I think I'll leave like this.

You can close the issue, my approach cannot be easily integrated in the org-static-blog and I don't understand if someone might be interested into this.
Otherwise, if someone is interested, I can consider to try to integrate it as optional configurable variable, since I don't think it's would be great to break the links of the current blogs.

from org-static-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.