Skip to content

Commit 61ca78e

Browse files
committed
Add og metadata
1 parent 0048878 commit 61ca78e

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

lib/rdoc/generator/template/aliki/_head.rhtml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,48 @@
3030
<link rel="canonical" href="<%= canonical_url %>">
3131
<%- end -%>
3232

33+
<!-- Open Graph / Facebook -->
34+
<meta property="og:type" content="website">
35+
<meta property="og:title" content="<%= h @title %>">
36+
<%- if defined?(klass) -%>
37+
<%- if klass.comment.empty? -%>
38+
<meta property="og:description" content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples">
39+
<%- else -%>
40+
<meta property="og:description" content="<%= h excerpt(klass.comment) %>">
41+
<%- end -%>
42+
<%- elsif defined?(file) -%>
43+
<%- if file.comment.empty? -%>
44+
<meta property="og:description" content="<%= h file.page_name %> - <%= h @title %> documentation">
45+
<%- else -%>
46+
<meta property="og:description" content="<%= h excerpt(file.comment) %>">
47+
<%- end -%>
48+
<%- else -%>
49+
<meta property="og:description" content="API documentation for <%= h @title %> - Browse classes, modules, and methods">
50+
<%- end -%>
51+
<%- if canonical_url = @options.canonical_root -%>
52+
<% canonical_url = current.canonical_url if defined?(current) %>
53+
<meta property="og:url" content="<%= canonical_url %>">
54+
<%- end -%>
55+
56+
<!-- Twitter -->
57+
<meta name="twitter:card" content="summary">
58+
<meta name="twitter:title" content="<%= h @title %>">
59+
<%- if defined?(klass) -%>
60+
<%- if klass.comment.empty? -%>
61+
<meta name="twitter:description" content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples">
62+
<%- else -%>
63+
<meta name="twitter:description" content="<%= h excerpt(klass.comment) %>">
64+
<%- end -%>
65+
<%- elsif defined?(file) -%>
66+
<%- if file.comment.empty? -%>
67+
<meta name="twitter:description" content="<%= h file.page_name %> - <%= h @title %> documentation">
68+
<%- else -%>
69+
<meta name="twitter:description" content="<%= h excerpt(file.comment) %>">
70+
<%- end -%>
71+
<%- else -%>
72+
<meta name="twitter:description" content="API documentation for <%= h @title %> - Browse classes, modules, and methods">
73+
<%- end -%>
74+
3375
<script type="text/javascript">
3476
var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
3577
var index_rel_prefix = "<%= h rel_prefix %>/";

0 commit comments

Comments
 (0)