Skip to content

Commit 8ba2fd2

Browse files
committed
new article prop
1 parent fbc4f29 commit 8ba2fd2

File tree

6 files changed

+23
-4
lines changed

6 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- Fix a bug where the results of the `JSON` function in sqlite would be interpreted as a string instead of a json object.
3333
- Fix a bug where the `sqlpage.environment_variable` function would return an error if the environment variable was not set. Now it returns `null` instead.
3434
- Update ApexCharts to [v4.3.0](https://github.com/apexcharts/apexcharts.js/releases/tag/v4.3.0).
35+
- New `article` property in the text component to display text in a more readable, article-like format.
3536

3637
## 0.31.0 (2024-11-24)
3738

examples/official-site/blog.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ where ($post IS NULL AND sqlpage.path() <> '/blog.sql') OR ($post IS NOT NULL AN
44
select 'dynamic' as component, properties FROM example WHERE component = 'shell' LIMIT 1;
55

66
SELECT 'text' AS component,
7+
true as article,
78
content AS contents_md
89
FROM blog_posts
910
WHERE title = $post;

examples/official-site/component.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ select 'SQLPage' as title, '/' as link, 'Home page' as description;
1818
select 'Components' as title, '/documentation.sql' as link, 'List of all components' as description;
1919
select $component as title, '/component.sql?component=' || sqlpage.url_encode($component) as link;
2020

21-
select 'text' as component, 'component' as id,
21+
select 'text' as component, 'component' as id, true as article,
2222
format('# The **%s** component
2323
2424
%s', $component, description) as contents_md

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
141141
('html', 'Raw html code to include on the page. Don''t use that if you are not sure what you are doing, it may have security implications.', 'TEXT', TRUE, TRUE),
142142
('contents', 'A top-level paragraph of text to display, without any formatting, without having to make additional queries.', 'TEXT', TRUE, TRUE),
143143
('contents_md', 'Rich text in the markdown format. Among others, this allows you to write bold text using **bold**, italics using *italics*, and links using [text](https://example.com).', 'TEXT', TRUE, TRUE),
144+
('article', 'Makes long texts more readable by increasing the line height, adding margins, using a serif font, and decorating the initial letter.', 'BOOLEAN', TRUE, TRUE),
144145
-- item level
145146
('contents', 'A span of text to display', 'TEXT', FALSE, FALSE),
146147
('contents_md', 'Rich text in the markdown format. Among others, this allows you to write bold text using **bold**, italics using *italics*, and links using [text](https://example.com).', 'TEXT', FALSE, TRUE),
@@ -156,7 +157,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
156157

157158
INSERT INTO example(component, description, properties) VALUES
158159
('text', 'Rendering a simple text paragraph.', json('[{"component":"text", "contents":"Hello, world ! <3"}]')),
159-
('text', 'Rendering rich text using markdown', json('[{"component":"text", "contents_md":"\n'||
160+
('text', 'Rendering rich text using markdown', json('[{"component":"text", "article": true, "contents_md":"\n'||
160161
'# Markdown in SQLPage\n\n' ||
161162
'## Simple formatting\n\n' ||
162163
'SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, [external links](https://github.com/sqlpage/SQLPage), [links to other pages](/index.sql) and [intra-page links](#my-paragraph). \n\n' ||

sqlpage/sqlpage.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@ code {
8787
background: var(--tblr-bg-surface-secondary);
8888
box-shadow: 3px 0 3px var(--tblr-border-color);
8989
}
90+
91+
.article-text {
92+
font-size: 1.2em;
93+
line-height: 1.5em;
94+
font-family: 'Times New Roman', serif;
95+
max-width: 65ch;
96+
margin: 1.5em auto;
97+
}
98+
99+
.article-text p::first-letter {
100+
font-size: 1.2em;
101+
font-weight: 500;
102+
}
103+

sqlpage/templates/text.handlebars

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
{{/if}}
88
{{~/if~}}
99
{{~#if contents_md~}}
10-
<div class="remove-bottom-margin">{{{markdown contents_md}}}</div>
10+
<div class="remove-bottom-margin {{#if center}}mx-auto{{/if}} {{#if article}}markdown article-text{{/if}}">
11+
{{{~markdown contents_md~}}}
12+
</div>
1113
{{~/if~}}
12-
<p class="{{#if center}}mx-auto{{/if}}">
14+
<p class="{{#if center}}mx-auto{{/if}} {{#if article}}markdown article-text{{/if}}">
1315
{{contents}}
1416
{{~#each_row~}}
1517
{{~#if break~}}</p><p>{{~/if~}}

0 commit comments

Comments
 (0)