Skip to content

Commit e3aac49

Browse files
committed
Add basic search of wai arai practices spec
1 parent 5c276c7 commit e3aac49

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

apps/components_guide/lib/components_guide/research/spec.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ defmodule ComponentsGuide.Research.Spec do
4646
|> Floki.raw_html()
4747
end
4848

49+
def search_for(:wai_aria_practices, query) when is_binary(query) do
50+
url = "https://www.w3.org/TR/wai-aria-practices/"
51+
{:ok, document} = Source.html_document_at(url)
52+
53+
document
54+
|> Floki.find("#toc li a")
55+
# |> Floki.find("#id-#{query}")
56+
|> Floki.raw_html()
57+
end
58+
4959
def search_for(:bundlephobia, query) when is_binary(query) do
5060
{:ok, data} = Source.json_at("https://bundlephobia.com/api/size?package=#{query}")
5161

apps/components_guide_web/lib/components_guide_web/controllers/research_controller.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ defmodule ComponentsGuideWeb.ResearchController do
5151
h2("HTML spec"),
5252
Spec.search_for(:whatwg_html_spec, query) |> present_results()
5353
]),
54+
content_tag(:article, [
55+
h2("ARIA Practices"),
56+
Spec.search_for(:wai_aria_practices, query) |> present_results()
57+
]),
5458
content_tag(:article, [
5559
h2("HTML ARIA"),
5660
Spec.search_for(:html_aria_spec, query) |> present_results()

0 commit comments

Comments
 (0)