Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for the newest configuration files basename convention #79

Merged
merged 2 commits into from
Jan 29, 2024

Conversation

ttybitnik
Copy link
Contributor

From v0.109.0 on, Hugo started using hugo as basename for its configuration files (https://gohugo.io/getting-started/configuration/#configuration-file).

I've updated the easy-hugo-open-config function to support this new naming convention along with the old one.

Tested locally with both basenames and worked fine.

@masasam masasam merged commit 1628125 into masasam:master Jan 29, 2024
@masasam
Copy link
Owner

masasam commented Jan 29, 2024

Hi @ttybitnik !
Thank you for PR!
I didn't know about this, so I've merged immediately.

@ttybitnik
Copy link
Contributor Author

Hehe, fine. Actually, I think we will have to change it a bit.

I didn't see a void symbol warning for the return. Checking it now.

@masasam
Copy link
Owner

masasam commented Jan 29, 2024

An error is displayed even if the file exists.

let: No Hugo config file found in ~/src/github.com/masasam/solistblog/
let: No Hugo config file found in ~/src/github.com/masasam/solist/
let: No Hugo config file found in ~/src/github.com/masasam/PPAP/

@ttybitnik
Copy link
Contributor Author

Yes, breaking the dolist was just wrong. I had an eglot warning that did'nt let me see these warnings.

Seems like this should do the trick.

(defun easy-hugo-open-config ()
  "Open Hugo's config file."
  (interactive)
  (easy-hugo-with-env
   (let ((config-files '("config.toml" "config.yaml" "config.json"
                         "hugo.toml" "hugo.yaml" "hugo.json")))
     (catch 'found-config
       (dolist (file config-files)
         (let ((full-path (expand-file-name file easy-hugo-basedir)))
           (when (file-exists-p full-path)
             (find-file full-path)
             (throw 'found-config t))))
       (error "No Hugo config file found in %s" easy-hugo-basedir)))))

Otherwise, we can just go back to the cond and add new lists for the new basename.

@masasam
Copy link
Owner

masasam commented Jan 29, 2024

It's perfect because there are no more errors.
Would you like to pull request additionally?
Or should I commit this?

@ttybitnik
Copy link
Contributor Author

Nice then. Please go ahead.

And sorry for not seeing this before the PR. My eglot warning got me in this one hehe

@masasam
Copy link
Owner

masasam commented Jan 29, 2024

I got it. I'll commit it here.
Thank you for always helping me here.

@ttybitnik ttybitnik deleted the feat/config-basename branch January 29, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants