FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(netlify): restore sanity example deployment by osnoser1 · Pull Request #29 · limitless-angular/limitless-angular · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (1) .md  (3) .toml  (1) .ts  (2) .yaml  (1) All 5 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions apps/sanity-example/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@angular-devkit/build-angular": "~19.0.4",
"@angular/cli": "~19.0.4",
"@angular/compiler-cli": "~19.0.3",
"@netlify/angular-runtime": "4.0.0",
"@tailwindcss/typography": "^0.5.13",
"@types/express": "4.17.14",
"@types/leaflet": "^1.9.12",
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
computed,
inject,
PLATFORM_ID,
type ProviderToken,
} from '@angular/core';
import { isPlatformBrowser, isPlatformServer } from '@angular/common';

Expand All @@ -12,17 +13,22 @@ import { type Request as ExpressRequest } from 'express';

import { REQUEST } from '../../server.tokens';

const NETLIFY_REQUEST = 'netlify.request' as unknown as ProviderToken<Request>;

// FIXME: request token isn't injected with `ng serve` see: https://github.com/angular/angular-cli/issues/26323
const getLanguagesFn = () => {
const platformId = inject(PLATFORM_ID);
const expressRequest = inject<ExpressRequest>(REQUEST, { optional: true });
const netlifyRequest = inject<Request>(NETLIFY_REQUEST, { optional: true });

return () => {
if (isPlatformServer(platformId) && expressRequest) {
const acceptLanguageHeader = expressRequest.headers['accept-language'];
const acceptLanguage = Array.isArray(acceptLanguageHeader)
if (isPlatformServer(platformId) && (expressRequest || netlifyRequest)) {
const acceptLanguageHeader = expressRequest?.headers['accept-language'];
const expressAcceptLanguage = Array.isArray(acceptLanguageHeader)
? acceptLanguageHeader.join(',')
: acceptLanguageHeader;
const acceptLanguage =
expressAcceptLanguage ?? netlifyRequest?.headers.get('accept-language');

if (acceptLanguage) {
return acceptLanguage
Expand Down
14 changes: 12 additions & 2 deletions apps/sanity-example/src/server.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { APP_BASE_HREF } from '@angular/common';
import { CommonEngine, isMainModule } from '@angular/ssr/node';
import express, { type Request, type Response } from 'express';
import { render } from '@netlify/angular-runtime/common-engine.js';
import express, {
type Request as ExpressRequest,
type Response as ExpressResponse,
} from 'express';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import bootstrap from './main.server';
import { REQUEST, RESPONSE } from './server.tokens';

const netlifyCommonEngine = new CommonEngine();

export async function netlifyCommonEngineHandler(): Promise<globalThis.Response> {
return await render(netlifyCommonEngine);
}

export function app(): express.Express {
const server = express();
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
Expand All @@ -24,7 +34,7 @@ export function app(): express.Express {
}),
);

server.get('**', (req: Request, res: Response, next) => {
server.get('**', (req: ExpressRequest, res: ExpressResponse, next) => {
const { protocol, originalUrl, baseUrl, headers } = req;

commonEngine
Expand Down
10 changes: 10 additions & 0 deletions netlify.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build]
base = "apps/sanity-example"
command = "pnpm turbo run build --filter=sanity-example"
publish = "dist/sanity-example/browser"

[build.environment]
NODE_VERSION = "22.22.3"

[[plugins]]
package = "@netlify/angular-runtime"
1 change: 1 addition & 0 deletions packages/sanity/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Limitless Angular is a powerful collection of Angular libraries focused on Sanit

## Quick Links

- 🚀 [Portable Text Live Demo](https://limitless-angular-sanity-example.netlify.app/)
- 💻 [Example Project](/apps/sanity-example)
- 📦 [NPM Package](https://www.npmjs.com/package/@limitless-angular/sanity)

Expand Down
1 change: 1 addition & 0 deletions packages/sanity/image-loader/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export const appConfig: ApplicationConfig = {

## Examples & Resources

- [Live Demo](https://limitless-angular-sanity-example.netlify.app/)
- [Example Source Code](https://github.com/limitless-angular/limitless-angular/tree/main/apps/sanity-example)
- [Sanity Image URL Builder docs](https://www.sanity.io/docs/image-url)
- [NgOptimizedImage docs](https://angular.io/api/common/NgOptimizedImage)
4 changes: 3 additions & 1 deletion packages/sanity/portabletext/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Render [Portable Text](https://portabletext.org/) with Angular.

## Demo

See the example project in the monorepo: [`apps/sanity-example`](/apps/sanity-example)
Check out our live demo of the Sanity example here: [Limitless Angular Sanity Example](https://limitless-angular-sanity-example.netlify.app/)

You can also see the example project in the monorepo: [`apps/sanity-example`](/apps/sanity-example)

## Table of contents

Expand Down
44 changes: 35 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

Back | FazBrowse Home | New Git URL