Skip to content

Commit 0fedfd6

Browse files
authored
Merge pull request #366 from remote-jp/add-schema-org-organization
Schema.org Organization タイプを企業ページに追加
2 parents bedc197 + b774c19 commit 0fedfd6

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

docs/Rakefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ require 'html-proofer'
2222
# cf. GitHub - gjtorikian/html-proofer
2323
# https://github.com/gjtorikian/html-proofer
2424

25+
# Load custom checks
26+
Dir['_tests/*.rb'].each { |file| require_relative file }
27+
2528
task test: [:build] do
2629
options = {
2730
allow_hash_href: true,
2831
disable_external: true,
29-
checks: ['Links', 'Images', 'OpenGraph', 'Favicon'],
32+
checks: ['Links', 'Images', 'OpenGraph', 'Favicon', 'JsonLdCheck'],
3033

3134
# NOTE: You can ignore file, URL, and response as follows
3235
ignore_files: [

docs/_data/translations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ viewOnGitHub:
1414

1515
titleDescription:
1616
en: 'Tech companies in Japan that hire remote workers.'
17-
ja: 'Tech companies in Japan that hire remote workers.'
17+
ja: 'リモートワークを採用している日本のテクノロジー企業のまとめ。'
1818

1919
searchPlaceholder:
2020
en: 'e.g. '

docs/_includes/head.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,15 @@
6262
<meta name="twitter:card" content="summary">
6363
<meta name="twitter:image" content="{{ site.url }}/assets/img/twitter_card.png">
6464
<meta itemprop="image" content="{{ site.url }}/assets/img/twitter_card.png">
65+
66+
<!-- Schema.org JSON-LD -->
67+
{% if page.layout == 'post' and page.domain %}
68+
<script type="application/ld+json">
69+
{% include organization-json-ld.json %}
70+
</script>
71+
{% else %}
72+
<script type="application/ld+json">
73+
{% include website-json-ld.json %}
74+
</script>
75+
{% endif %}
6576
</head>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "Organization",
4+
"name": "{{ page.title }}",
5+
"url": "{{ page.link }}",
6+
"description": {{ page.description | jsonify }},
7+
"address": {
8+
"@type": "PostalAddress",
9+
"addressCountry": "JP"
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": "https://schema.org",
3+
"@type": "WebSite",
4+
"name": "{{ site.title }}",
5+
"url": "{{ site.url }}/",
6+
"description": "{{ site.data.translations.titleDescription[page.lang] }}",
7+
"inLanguage": ["en", "ja"]
8+
}

docs/_tests/json_ld_check.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require 'json'
4+
5+
class JsonLdCheck < HTMLProofer::Check
6+
def run
7+
@html.css('script[type="application/ld+json"]').each do |script|
8+
check_json_ld(script)
9+
end
10+
end
11+
12+
private
13+
14+
def check_json_ld(script)
15+
json_text = script.content.strip
16+
17+
# Check if JSON is valid
18+
begin
19+
JSON.parse(json_text)
20+
rescue JSON::ParserError => e
21+
add_failure("Invalid JSON-LD: #{e.message}")
22+
end
23+
end
24+
end

0 commit comments

Comments
 (0)