Comments (3)
jekyll-compose is pretty close to what you're asking, if I understand correctly.
from jekyll.
If it is just _posts, if you define the defaults
default layout in _config.yml, the author, then the preamble option does not need to be defined, but according to your description, I guess you want to use automation, which can write a _plugins/ create_post.rb
require 'fileutils'
Jekyll::Hooks.register :site, :after_init do |site|
# 定义_posts目录路径
posts_dir = File.join(site.source, '_posts')
# 获取当前日期并创建文件名
today = Date.today.strftime('%Y-%m-%d')
filename = "#{today}-new-post.md"
# 拼接文件路径
filepath = File.join(posts_dir, filename)
# 检查文件是否已存在
if File.exist?(filepath)
puts "文件 #{filename} 已存在,无需创建。"
else
# 创建文件并写入初始内容
File.open(filepath, 'w') do |file|
file.puts '---'
file.puts 'layout: post'
file.puts "title: Your Title Here"
file.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
file.puts 'categories: [category1, category2]'
file.puts 'tags: [tag1, tag2]'
file.puts '---'
file.puts ''
file.puts 'Write your content here.'
end
puts "文件 #{filename} 创建成功!"
end
end
This is just an example, modify as needed
from jekyll.
This issue has been automatically marked as stale because it has not been commented on for at least two months.
The resources of the Jekyll team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the latest 3.x-stable
or master
/main
branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, please consider building it first as a plugin. Jekyll 3 introduced hooks which provide convenient access points throughout the Jekyll build pipeline whereby most needs can be fulfilled. If this is something that cannot be built as a plugin, then please provide more information about why in order to keep this issue open.
This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.
from jekyll.
Related Issues (20)
- Update dependency constraint to allow for activesupport v7.1.1 HOT 1
- Update dependency constraint to allow for activesupport v7.1.1
- Update dependency constraint to allow for rubocop v1.57.2 HOT 2
- [Bug]: bundle exec jekyll build fails on Debian Unstable HOT 1
- Blog start
- [Bug]: Jekyll can support html in markdown ? HOT 1
- Update dependency constraint to allow for activesupport v7.1.1 HOT 2
- feat: multi-thread rendering HOT 10
- [Bug]: jekyll build fails with Variable was not properly terminated with regexp: /\\}\\}/ (Liquid::SyntaxError) HOT 1
- [Bug]: jekyll not working after upgrade from Debian 11 to 12 HOT 2
- [Bug]: Jekyll Github Pages site doesn't "play nice" with Ruby versions required by vscode HOT 1
- Time for a new release
- > ¡Hola! 👋 HOT 1
- feat: OpenBSD support HOT 6
- Found CRITICAL Vulnerability in your website! HOT 1
- [Bug]: LiveReload websocket crashes over HTTPS/WSS HOT 1
- [Bug]: jekyll serve does not detach when spawned without shell HOT 1
- [Docs]: Urgent: Specify json gem version for Jekyll 4.3.2
- [Bug]: livereload-ignore option doesn't work HOT 1
- [Bug]: Liquid Exception: divided by 0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jekyll.