Skip to content

Commit f558195

Browse files
committed
Update raw_content_for_collections.rb
1 parent ec24cca commit f558195

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

_plugins/raw_content_for_collections.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,20 @@ class RawContentForCollections < Generator
55
priority :low
66

77
def generate(site)
8-
# 遍历所有集合
98
site.collections.each do |label, collection|
10-
next unless label == 'articles' # 只处理 articles 集合
9+
next unless label == 'articles'
1110

1211
collection.docs.each do |doc|
13-
# 获取源文件的完整路径
1412
source_path = File.join(site.source, doc.relative_path)
1513
if File.exist?(source_path)
16-
# 读取原始内容(注意:包含 Front Matter)
1714
raw_file_content = File.read(source_path)
1815

19-
# 可选:移除 Front Matter,只保留正文 Markdown
20-
# 如果你希望 raw_content 不包含 Front Matter,取消下面注释
21-
# raw_markdown = remove_front_matter(raw_file_content)
22-
23-
# 这里我们保留整个文件内容(含 Front Matter)
2416
doc.data['raw_content'] = raw_file_content
2517
end
2618
end
2719
end
2820
end
2921

30-
# 可选辅助方法:移除 Front Matter,仅保留 Markdown 正文
3122
private
3223

3324
def remove_front_matter(content)

0 commit comments

Comments
 (0)