Skip to content

Commit dd2f748

Browse files
authored
Merge pull request #439 from amrutadotorg/patch-11
Enhanced Font Management with Local and Google Fonts In the shell component
2 parents a128ad0 + 8935071 commit dd2f748

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
779779
('search_target', 'When this is set, a search field will appear in the top navigation bar, and load the specified sql file with an URL parameter named "search" when the user searches something.', 'TEXT', TRUE, TRUE),
780780
('search_value', 'This value will be placed in the search field when "search_target" is set. Using the "$search" query parameter value will mirror the value that the user has searched for.', 'TEXT', TRUE, TRUE),
781781
('norobot', 'Forbids robots to save this page in their database and follow the links on this page. This will prevent this page to appear in Google search results for any query, for instance.', 'BOOLEAN', TRUE, TRUE),
782-
('font', 'Name of a font to display the text in. This has to be a valid font name from fonts.google.com.', 'TEXT', TRUE, TRUE),
782+
('font', 'Specifies the font to be used for displaying text, which can be a valid font name from fonts.google.com or the path to a local WOFF2 font file starting with a slash (e.g., "/fonts/MyLocalFont.woff2").', 'TEXT', TRUE, TRUE),
783783
('font_size', 'Font size on the page, in pixels. Set to 18 by default.', 'INTEGER', TRUE, TRUE),
784784
('language', 'The language of the page. This can be used by search engines and screen readers to determine in which language the page is written.', 'TEXT', TRUE, TRUE),
785785
('refresh', 'Number of seconds after which the page should refresh. This can be useful to display dynamic content that updates automatically.', 'INTEGER', TRUE, TRUE),

sqlpage/templates/shell.handlebars

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,31 @@
1010
<link rel="manifest" href="{{manifest}}">
1111
{{/if}}
1212
<link rel="stylesheet" href="{{static_path 'sqlpage.css'}}">
13-
{{#each (to_array css)}}
13+
{{#each (to_array css)}}
1414
{{#if this}}
1515
<link rel="stylesheet" href="{{this}}">
1616
{{/if}}
17-
{{/each}}
17+
{{/each}}
1818

19-
{{#if font}}
20-
<link rel="preconnect" href="https://fonts.googleapis.com">
21-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
22-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family={{font}}&display=fallback">
23-
<style>:root { --tblr-font-sans-serif: '{{font}}', Arial, sans;}</style>
19+
{{#if font}}
20+
{{#if (startsWith font "/")}}
21+
<style>
22+
@font-face {
23+
font-family: 'LocalFont';
24+
src: url('{{font}}') format('woff2');
25+
font-weight: normal;
26+
font-style: normal;
27+
}
28+
:root {
29+
--tblr-font-sans-serif: 'LocalFont', Arial, sans-serif;
30+
}
31+
</style>
32+
{{else}}
33+
<link rel="preconnect" href="https://fonts.googleapis.com">
34+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
35+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family={{font}}&display=fallback">
36+
<style>:root { --tblr-font-sans-serif: '{{font}}', Arial, sans-serif;}</style>
37+
{{/if}}
2438
{{/if}}
2539

2640
<script src="{{static_path 'sqlpage.js'}}" defer></script>

0 commit comments

Comments
 (0)