-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.rb
146 lines (117 loc) · 3.77 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
require "lib/url_helpers"
### Config from tech-docs-gem: start ###
require "middleman"
require "middleman-autoprefixer"
require "middleman-sprockets"
require "middleman-livereload"
require "middleman-search"
require "active_support/all"
require "lib/govuk_tech_docs/contribution_banner"
require "lib/govuk_tech_docs/meta_tags"
require "lib/govuk_tech_docs/tech_docs_html_renderer"
require "lib/govuk_tech_docs/unique_identifier_extension"
require "lib/govuk_tech_docs/unique_identifier_generator"
# Project setup
project_name = "standards-catalogue"
activate :sprockets
sprockets.append_path File.expand_path("node_modules", __dir__)
files.watch :source, path: File.expand_path("source", __dir__)
set :markdown_engine, :redcarpet
set :markdown,
renderer: GovukTechDocs::TechDocsHTMLRenderer.new(
with_toc_data: true,
context: self,
),
fenced_code_blocks: true,
tables: true,
no_intra_emphasis: true
# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end
set(:govuk_assets_path, "/assets/govuk/assets/")
configure :build do
set(:build_dir, "build/#{project_name}")
set(:http_prefix, "/#{project_name}/")
set(:govuk_assets_path, "/#{project_name}/assets/govuk/assets/")
end
configure :build do
activate :autoprefixer
activate :minify_javascript, ignore: ["/raw_assets/*"]
end
config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml")
config[:tech_docs] = YAML.load_file(config_file).with_indifferent_access
activate :unique_identifier
helpers do
include GovukTechDocs::ContributionBanner
def meta_tags
@meta_tags ||= GovukTechDocs::MetaTags.new(config, current_page)
end
def format_date(date)
date.strftime("%-e %B %Y")
end
def active_page(page_path)
[
page_path == "/" && current_page.path == "index.html",
("/" + current_page.path) == page_path,
!current_page.data.parent.nil? && current_page.data.parent.to_s == page_path,
].any?
end
end
page "/*.xml", layout: false
page "/*.json", layout: false
page "/*.txt", layout: false
activate :search do |search|
search.resources = [""]
search.fields = {
title: { boost: 100, store: true, required: true },
content: { boost: 50, store: true },
url: { index: false, store: true },
}
search.pipeline_remove = %w[stopWordFilter]
search.tokenizer_separator = '/[\s\-/]+/'
end
### Config from tech-docs-gem: end ###
helpers UrlHelpers
# catalogue_csv = File.expand_path("data/catalogue.csv", __dir__)
# organisation_csv = File.expand_path("data/organisation.csv", __dir__)
# api_catalogue = ApiCatalogue.from_csv(catalogue_csv: catalogue_csv, organisation_csv: organisation_csv)
# Order organisations from A-Z in the Table of Contents,
# leaving a buffer from 0-999 for static content to be given priority
# initial_org_weight = 1_000
# api_catalogue.organisations_apis.each.with_index(initial_org_weight) do |(organisation, apis), org_weight|
# proxy(
# UrlHelpers.organisation_path(organisation),
# "organisation_index.html",
# locals: { organisation: organisation, apis: apis },
# data: {
# title: organisation.name,
# weight: org_weight,
# },
# ignore: true,
# )
# apis.each_with_index do |api, api_weight|
# proxy(
# UrlHelpers.api_path(organisation: organisation, api: api),
# "api_details.html",
# locals: { api: api },
# data: {
# title: api.name,
# weight: api_weight,
# },
# ignore: true,
# )
# end
# end
# proxy(
# "/dashboard/index.html",
# "dashboard.html",
# locals: { dashboard_stats: DashboardStats.new(api_catalogue) },
# ignore: true,
# )
# proxy(
# "/index/index.html",
# "overview_index.html",
# locals: { overview: ApiCatalogueOverview.new(api_catalogue) },
# ignore: true,
# )