-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saber Functions #183
Comments
Maybe "Functional Routes" or "Manual Routes"? |
#72 won't be needed if we have this feature instead. |
@issuehunt has funded $150.00 to this issue.
|
In NuxtPress (currently in development), I did a generic abstraction of this. Every source is identified by a full path. For every source, the engine automatically does a GET request to If you don't provide your own API handlers, it will perform static A source is a JSON with So in generate mode, if you have a route A Then agan, if you do provide your own API handlers, data can come from anywhere you like. |
I also quite like the implementation that Sapper uses: https://sapper.svelte.dev/docs#Server_routes |
Just updated the proposal ⬆️ |
I'm currently building something similar: rollup-plugin-computed |
Is this project still being worked on? The website seems parked by adware/viruses. If it is, I can take a look at this issue. |
RFC: Saber Functions
functions
folderFunctions are used to fetch data that you can inject to pages at build time, let's say you have a
posts.js
insidefunctions
folder:Since we need to get the return value before running webpack, you can only write JavaScript with features supported by your system's Node version.
Then a function called
posts
will be available and you can use it like this in a page:By using
injectProps
here Saber will call the function at build time and inline result in your JavaScript bundle.Pagination
We can create pagination based on injected props:
Exporting function
A function can be exported as a page just like a normal page, only thing you need to do is setting
config.export
option totrue
:When
export
istrue
, Saber automatically infers the actual link from its filename, in this case it would be/atom.xml
. You can also set it to astring
to use whatever permalink you want, e.g./subscribe/rss.xml
.When
export
istrue
, the function's argument would beundefined
unless you use dynamic parameter in its filename, for examplefunctions/pages/[slug].json.js
:Because the path is dynamic you also need
getStaticPaths
to define a list of paths that need to be rendered at build time.Now when you visit
/pages/hello-world.json
, then function argument will be{ slug: 'hello-world' }
Adding a function from plugins
IssueHunt Summary
Backers (Total: $150.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
IssueHunt has been backed by the following sponsors. Become a sponsor
The text was updated successfully, but these errors were encountered: