Skip to content

Commit

Permalink
Small fixes to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alansemenov committed Oct 24, 2024
1 parent ab2be5f commit cf868e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Function that returns a cache control header value.

It's used as a callback and is the default value for the `cacheControl` option in the <<api/requestHandler,requestHandler>> function.

When yielded inside the requestHandler it gets passed the found resource, it's content type and path.
When yielded inside the requestHandler it gets passed the found resource, its content type and path.

=== Type signature

Expand Down Expand Up @@ -108,7 +108,7 @@ Single page applications (SPA) typically consists of some static assets (stylesh

Whenever a request doesn't match a static asset, lib-static would by default return a 404 Response.

This is not desireable for a SPA, because the request might be to a client-side routed page, and not a missing static asset.
This is not desirable for an SPA, because the request might be to a client-side routed page, and not a missing static asset.

Such requests can happen when someone reloads or opens a bookmarked url to a client-side routed page.

Expand Down Expand Up @@ -209,4 +209,4 @@ interface RequestHandlerOptions {
staticCompress?: boolean
throwErrors?: boolean
}
----
----
10 changes: 5 additions & 5 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

Achieve ultra-high performance with detailed control over edge and client caching for your static assets. Serve files bundled in your Enonic app (i.e. js, css + html) with fine-grained control over cache headers and error handling, suitable even for hosting static webapps and SPAs.

NOTE: For a more simplistic approach to asset hosting, check out <<https://developer.enonic.com/docs/lib-asset#, lib-asset>> instead.
NOTE: For a more simplistic approach to asset hosting, check out <<https://developer.enonic.com/docs/lib-asset, lib-asset>> instead.

== Usage

There are many ways of setting up and using lib-static, the gist is:

. Add a dependency to lib-static
. Place your files in the `/src/main/resources/static/` folder
. Use a <<usage#, service, mapping or webapp>> to devliver the assets.
. Use relative links, or create links to assets from your controllers
. Use a <<usage#, service, mapping or webapp>> to deliver the assets.
. Use relative links, or create links to assets from your controllers

We have created hands on <<usage#, usage examples>> to give you a flying start.
We have created hands-on <<usage#, usage examples>> to give you a flying start.

For more details, visit the <<api#, API documentation>>
For more details, visit the <<api#, API documentation>>
18 changes: 10 additions & 8 deletions docs/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

== Introduction

There are multiple ways of deploying and using lib-static in your application. Below we expore the most common approaches. This includes how you may setup lib-static to service different files, using different cache headers.
There are multiple ways of deploying and using lib-static in your application. Below we expore the most common approaches. This includes how you may set up lib-static to service different files, using different cache headers.

== Common

Follow these initial steps to get started, they are common for all examples below:
Follow these initial steps to get started, they are common for all the examples below:

. Use an existing Enonic app, or create a new one with the following command:
+
Expand All @@ -30,7 +30,7 @@ You can now move on to the various examples below:

== Service example

This demonstrates how to serve asset using an https://developer.enonic.com/docs/xp/stable/runtime/engines/http-service[http service].
This demonstrates how to serve assets using a https://developer.enonic.com/docs/xp/stable/runtime/engines/http-service[http service].

====
This example showcases:
Expand Down Expand Up @@ -58,7 +58,7 @@ include::../src/main/resources/services/myStatic/myStatic.ts[]
include::../src/main/resources/static/css/style.css[]
----
+
NOTE: `/src/main/resources/static/` is the default location lib static will look for the files
NOTE: `/src/main/resources/static/` is the default location where lib static will look for the files
+
. Add a page controller that links to the stylesheet.
+
Expand All @@ -73,7 +73,7 @@ include::../src/main/resources/site/pages/dynamic/dynamic.ts[]

== Site mapping example

Developers using site engine, may want to serve the assets from a pretty URL, rather than a service endpoint.
Developers using site engine may want to serve the assets from a pretty URL, rather than a service endpoint.

====
This example demonstrates
Expand Down Expand Up @@ -114,8 +114,10 @@ include::../src/main/resources/site/controllers/myController/files/css/styles.cs

Lib static is also capable of acting like a webserver, serving html-files. In this example we use XP's /webapp feature to do the job. To make the example as realistic as possible, we use a React SPA created with Vite.

TIP: Read more about <<https://developer.enonic.com/docs/xp/stable/runtime/engines/webapp-engine, XP webapps>>

====
Showcases advanced use-cases like:
This example demonstrates advanced use-cases like:
* Custom Cache control handling
* Fallback handling to SPA file for 404
Expand All @@ -135,7 +137,7 @@ Showcases advanced use-cases like:
include::../src/vite/App.tsx[]
----
+
TIP: You may serve the webapp from any context path (and domain) using https://developer.enonic.com/docs/xp/stable/deployment/vhosts[vHosts]. Make sure the baseUrl in your React app is compliant with the deployment
TIP: You may serve the webapp from any context path (and domain) using https://developer.enonic.com/docs/xp/stable/deployment/vhosts[vHosts]. Make sure the baseUrl in your React app is compliant with the deployment.
+
. From the React app folder, build the static webapp:
+
Expand All @@ -152,7 +154,7 @@ TIP: You may serve the webapp from any context path (and domain) using https://d
include::../src/main/resources/webapp/webapp.ts[]
----
+
. Build and deploy the Enonic app containing the SPA, you should see the result by visting http://localhost:8080/webapp/com.example.static[http://localhost:8080/webapp/com.example.static^]
. Build and deploy the Enonic app containing the SPA, you should see the result by visiting http://localhost:8080/webapp/com.example.static[http://localhost:8080/webapp/com.example.static^]



Expand Down

0 comments on commit cf868e1

Please sign in to comment.