@@ -58,6 +58,8 @@ desc 'Build and preview the site locally in development mode'
5858task :preview do
5959 run_antora
6060 clone_versions
61+ create_context7_files ( )
62+
6163 system 'bundle install'
6264 system "#{ $use_bundle_exec ? 'bundle exec ' : '' } jekyll serve --host 0.0.0.0 --livereload" or raise "Jekyll build failed"
6365end
@@ -70,6 +72,9 @@ task :build, [:environment] do |task, args|
7072 system 'bundle install'
7173 system "JEKYLL_ENV=#{ args [ :environment ] } bundle exec jekyll build"
7274 clone_versions
75+
76+ create_context7_files ( )
77+
7378end
7479
7580desc 'Clean out generated site and temporary files'
@@ -130,7 +135,33 @@ def clone_versions()
130135 puts "Unable to find devel version dir"
131136 end
132137end
133-
138+
139+ def create_context7_files ( )
140+ base_path = "_site/documentation/reference"
141+ raise ArgumentError , "'#{ base_path } ' is not a directory" unless Dir . exist? ( base_path )
142+
143+ create_context7_file ( base_path , "debezium_io_reference" )
144+
145+ Dir . glob ( "#{ base_path } /*/" ) . each do |subdir |
146+ dir_name = File . basename ( subdir )
147+ slug = "debezium_io_reference_#{ dir_name . tr ( '.' , '_' ) } "
148+ create_context7_file ( subdir , slug )
149+ end
150+ end
151+
152+ def create_context7_file ( file_dir , slug )
153+ content = <<~JSON
154+ {
155+ "url": "https://context7.com/websites/#{ slug } ",
156+ "public_key": "pk_4bmn60gBy8u78Juf3Zn1c"
157+ }
158+ JSON
159+
160+ filepath = File . join ( file_dir , "context7.json" )
161+ File . write ( filepath , content )
162+ puts "Created: #{ filepath } "
163+ end
164+
134165# Execute Antora
135166def run_antora ( )
136167 puts "Generating Antora documentation using configuration: #{ $antora_config} "
0 commit comments