Skip to content

Commit d01fb24

Browse files
committed
add llms.txt
1 parent a847baa commit d01fb24

4 files changed

Lines changed: 96 additions & 0 deletions

File tree

_plugins/raw_content.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# _plugins/raw_content.rb
2+
module Jekyll
3+
class RawContentForCollections < Generator
4+
safe true
5+
priority :low
6+
7+
def generate(site)
8+
site.collections.each do |label, collection|
9+
10+
collection.docs.each do |doc|
11+
add_raw_content_to_document(site, doc)
12+
end
13+
end
14+
15+
site.pages.each do |page|
16+
add_raw_content_to_document(site, page)
17+
end
18+
19+
end
20+
21+
private
22+
23+
def add_raw_content_to_document(site, document)
24+
if document.respond_to?(:relative_path) && document.relative_path
25+
source_path = File.join(site.source, document.relative_path)
26+
elsif document.respond_to?(:path) && document.path
27+
source_path = document.path
28+
else
29+
return
30+
end
31+
32+
if File.exist?(source_path)
33+
raw_file_content = File.read(source_path, encoding: 'UTF-8')
34+
content_without_front_matter = remove_front_matter(raw_file_content)
35+
document.data['raw_content'] = content_without_front_matter
36+
end
37+
end
38+
39+
def remove_front_matter(content)
40+
if content =~ /\A---\s*\n.*?\n---\s*\n+/m
41+
result = content.sub(/\A---\s*\n.*?\n---\s*\n+/m, '')
42+
return result
43+
else
44+
return content
45+
end
46+
end
47+
end
48+
end

articles.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
layout: null
3+
sitemap: false
4+
---
5+
{
6+
"articles": [
7+
{% for article in site.pages %}
8+
{
9+
"title": {{ article.title | jsonify }},
10+
"url": "https://www.dynamsoft.com{{ article.url | relative_url }}",
11+
"content": {{ article.raw_content | jsonify }},
12+
"breadcrumb": {{ article.breadcrumbText | default: article.title | jsonify }}
13+
}{% unless forloop.last %},{% endunless %}
14+
{% endfor %}
15+
]
16+
}

llms-full.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout: null
3+
sitemap: false
4+
---
5+
{% for article in site.pages %}{% if article.title %}<page>
6+
---
7+
title: {{article.title}}
8+
description: {{article.description}}
9+
source_url:
10+
html: https://www.dynamsoft.com{{ article.url | relative_url }}
11+
md: {{ site.repositoryUrl }}/{{article.path}}
12+
---
13+
{{ article.raw_content }}
14+
</page>{% endif %}
15+
16+
{% endfor %}
17+

llms.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: null
3+
sitemap: false
4+
---
5+
6+
# Dynamsoft Document Viewer Docs
7+
8+
## Docs
9+
10+
{% for article in site.pages %}{% if article.title %}- [{{article.title}}](https://www.dynamsoft.com{{ article.url | relative_url }}): {{ article.description }}{% endif %}
11+
{% endfor %}
12+
13+
## Samples
14+
15+
- [Samples](https://github.com/Dynamsoft/document-viewer-samples/): Samples of Dynamsoft Document Viewer

0 commit comments

Comments
 (0)