Skip to content

Commit c760ecc

Browse files
committed
Fix problematic intra-page links wirh the text component
see #203
1 parent 49fd4f0 commit c760ecc

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Updated default graph colors so that all series are easily distinguishable even when a large number of series are displayed.
1212
- New `embed` attribute in the `card` component that lets you build multi-column layouts of various components with cards.
1313
- ![](./examples/cards-with-remote-content/screenshot.png)
14+
- Added `id` and `class` attributes to all components, to make it easier to style them with custom CSS and to reference them in intra-page links and custom javascript code.
1415

1516
## 0.17.1 (2023-12-10)
1617

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ INSERT INTO example(component, description, properties) VALUES
146146
('text', 'Rendering rich text using markdown', json('[{"component":"text", "contents_md":"\n'||
147147
'# Markdown in SQLPage\n\n' ||
148148
'## Simple formatting\n\n' ||
149-
'SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, and [links](index.sql).\n\n' ||
149+
'SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, [external links](https://github.com/lovasoa/sqlpage), [links to other pages](/index.sql) and [intra-page links](#my-paragraph). \n\n' ||
150150
'## Lists\n' ||
151151
'### Unordered lists\n' ||
152152
'* SQLPage is easy\n' ||
@@ -182,7 +182,16 @@ INSERT INTO example(component, description, properties) VALUES
182182
'{"contents":" is a domain-specific language used in programming and designed for managing data held in a "},'||
183183
'{"contents": "relational database management system", "link": "https://en.wikipedia.org/wiki/Relational_database"},'||
184184
'{"contents": ". It is particularly useful in handling structured data."}]')
185-
);
185+
),
186+
(
187+
'text',
188+
'An intra-page link to a section of the page.',
189+
json('[
190+
{"component":"text", "contents_md":"This is a link to the [next paragraph](#my-paragraph). You can open this link in a new tab and the page will scroll to the paragraph on load."},
191+
{"component":"text", "id": "my-paragraph", "contents_md": "This **is** the next paragraph."}
192+
]')
193+
)
194+
;
186195

187196
INSERT INTO component(name, icon, description) VALUES
188197
('form', 'cursor-text', 'A series of input fields that can be filled in by the user. ' ||

sqlpage/templates/text.handlebars

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{{{~html~}}}
22
{{#if title}}
33
<h1 id="{{id}}" class="mt-3 {{#if center}}text-center{{/if}}">{{title}}</h1>
4+
{{else}}
5+
{{#if id}}
6+
<a id="{{id}}"></a>
7+
{{/if}}
48
{{/if}}
59
{{#if contents_md}}
6-
{{{markdown contents_md}}}
10+
<div class="remove-bottom-margin">{{{markdown contents_md}}}</div>
711
{{/if}}
8-
<p class="{{#if center}}mx-auto{{/if}}" {{#if (not title)}}id="{{id}}"{{/if}}>
12+
<p class="{{#if center}}mx-auto{{/if}}">
913
{{contents}}
1014
{{~#each_row~}}
1115
{{~#if break~}}</p><p>{{~/if~}}

0 commit comments

Comments
 (0)