Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions _plugins/raw_content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# _plugins/raw_content.rb
module Jekyll
class RawContentForCollections < Generator
safe true
priority :low

def generate(site)
site.collections.each do |label, collection|

collection.docs.each do |doc|
add_raw_content_to_document(site, doc)
end
end

site.pages.each do |page|
add_raw_content_to_document(site, page)
end

end

private

def add_raw_content_to_document(site, document)
if document.respond_to?(:relative_path) && document.relative_path
source_path = File.join(site.source, document.relative_path)
elsif document.respond_to?(:path) && document.path
source_path = document.path
else
return
end

if File.exist?(source_path)
raw_file_content = File.read(source_path, encoding: 'UTF-8')
content_without_front_matter = remove_front_matter(raw_file_content)
document.data['raw_content'] = content_without_front_matter
end
end

def remove_front_matter(content)
if content =~ /\A---\s*\n.*?\n---\s*\n+/m
result = content.sub(/\A---\s*\n.*?\n---\s*\n+/m, '')
return result
else
return content
end
end
end
end
16 changes: 16 additions & 0 deletions articles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: null
sitemap: false
---
{
"articles": [
{% for article in site.pages %}
{
"title": {{ article.title | jsonify }},
"url": "https://www.dynamsoft.com{{ article.url | relative_url }}",
"content": {{ article.raw_content | jsonify }},
"breadcrumb": {{ article.breadcrumbText | default: article.title | jsonify }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
17 changes: 17 additions & 0 deletions llms-full.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
layout: null
sitemap: false
---
{% for article in site.pages %}{% if article.title %}<page>
---
title: {{article.title}}
description: {{article.description}}
source_url:
html: https://www.dynamsoft.com{{ article.url | relative_url }}
md: {{ site.repositoryUrl }}/{{article.path}}
---
{{ article.raw_content }}
</page>{% endif %}

{% endfor %}

15 changes: 15 additions & 0 deletions llms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
layout: null
sitemap: false
---

# Dynamsoft Document Viewer Docs

## Docs

{% for article in site.pages %}{% if article.title %}- [{{article.title}}](https://www.dynamsoft.com{{ article.url | relative_url }}): {{ article.description }}{% endif %}
{% endfor %}

## Samples

- [Samples](https://github.com/Dynamsoft/document-viewer-samples/): Samples of Dynamsoft Document Viewer