Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
angularstatic
Advanced tools
Readme
A simple way to build static templates with Angular
Status: Infancy
NgModules
are not required. You can provide an Angular template and Angular Static will create the whole page.
import { renderModule, StaticModuleConfig } from 'angularstatic';
import { AppModule, Person } from './app.module';
async function render(module, config: StaticModuleConfig) {
const { document, url } = config;
const templateFn = await renderModule(AppModule, { document, url: '/' });
// pass in data for your app at a top-level
return await templateFn<Person>({
name: 'David',
interests: [
'Long walks on the beach',
'La Croix',
'Static websites'
]
});
}
AppModule
Angular Static takes a "top-down" approach for passing in data. This is similar to state management in React. Create a top-level Component
that injects a STATIC_CONTEXT
token. This STATIC_CONTEXT
token represents the data passed into your template function. Then include the top-level Component
in an NgModule
.
// app.module.ts
import { Component, NgModule, Input, Inject } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ServerModule } from '@angular/platform-server';
import { STATIC_CONTEXT } from 'angularstatic';
export interface Person { name: string, interests: string[]; };
@Component({
selector: 'app-root',
template: `
{{ context | json }}
`
})
export class AppComponent {
constructor( @Inject(STATIC_CONTEXT) public context: Person ) { }
}
@NgModule({
imports: [
BrowserModule.withServerTransition({ appId: 'my-app-id' }),
ServerModule,
],
declarations: [AppComponent],
exports: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
import { renderTemplate, StaticTemplateConfig } from 'angularstatic';
async function render(config: StaticTemplateConfig) {
const { document, url } = config;
const templateFn = await renderTemplate(`
Hi {{ name }}!
`, { document, url: '/' });
// pass in data for your app at a top-level
return await templateFn<Person>({ name: 'David' })
}
FAQs
A simple way to build static templates with Angular
The npm package angularstatic receives a total of 3 weekly downloads. As such, angularstatic popularity was classified as not popular.
We found that angularstatic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.