mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
feat(server): Add replace and scroll to Link.
This commit is contained in:
parent
1cce024339
commit
9d6ac04b09
@ -128,10 +128,12 @@ _ref:
|
||||
- `Link`: component`: Lowdefy standard Link React component used as links to pages or external urls. The following props apply:
|
||||
- `back: boolean`: When the link is clicked, trigger the browser back.
|
||||
- `home: boolean`: When the link is clicked, route to the home page.
|
||||
- `pageId: string`: When the link is clicked, route to the provided Lowdefy page.
|
||||
- `url: string`: When the link is clicked, route to an external url.
|
||||
- `input: object`: When the link is clicked, pass data as the input object to the next Lowdefy page. Can only be used with pageId link and newTab false. See [Input]( TODO: Link to input page? ).
|
||||
- `newTab: boolean`: When the link is clicked, open the page in a new browser tab.
|
||||
- `input: object`: When the link is clicked, pass data as the input object to the next Lowdefy page. See [Input]( TODO: Link to input page? ).
|
||||
- `pageId: string`: When the link is clicked, route to the provided Lowdefy page.
|
||||
- `replace: boolean`: Prevent adding a new entry into browser history by replacing the url instead of pushing into history. Can only be used with pageId link and newTab false.
|
||||
- `scroll: boolean`: Disable scrolling to the top of the page after page transition. Can only be used with pageId link and newTab false.
|
||||
- `url: string`: When the link is clicked, route to an external url.
|
||||
- `urlQuery: object`: When the link is clicked, pass data as a url query to the next Lowdefy page. See [url query]( TODO: Link to url query page? ).
|
||||
- `content: object`: Passed to `container` and `context` block categories. The `content` object with methods to render sub blocks into content areas. The method name is the same as the area key, for example, 'content.content()` renders a blocks default `content` area.
|
||||
- `events: object`: All events defined on the block in the Lowdefy app config.
|
||||
|
@ -22,7 +22,17 @@ const createLinkComponent = (lowdefy) => {
|
||||
</a>
|
||||
);
|
||||
};
|
||||
const sameOriginLink = ({ children, className, href, id, newTab, pageId, url }) => {
|
||||
const sameOriginLink = ({
|
||||
children,
|
||||
className,
|
||||
href,
|
||||
id,
|
||||
newTab,
|
||||
pageId,
|
||||
replace,
|
||||
scroll,
|
||||
url,
|
||||
}) => {
|
||||
if (newTab) {
|
||||
return (
|
||||
<a
|
||||
@ -37,7 +47,7 @@ const createLinkComponent = (lowdefy) => {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<NextLink href={href}>
|
||||
<NextLink href={href} replace={replace} scroll={scroll}>
|
||||
<a id={id} className={className}>
|
||||
{type.isFunction(children) ? children(pageId || url || id) : children}
|
||||
</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user