7 changed files with 105 additions and 3 deletions
@ -1,5 +1,5 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
yarn prod |
yarn prod |
||||
rsync -avz --delete --exclude '/apis/conn.conn' --exclude '.well-known' --exclude '/uploads' -e "ssh -i ./auth/identity.pem -p2222" ./dist/dslak-website/* cdr@2.238.194.8:/www/dslak.it/ |
|
||||
|
rsync -avz --delete --exclude '/apis/conn.conn' --exclude '/sitemap.xml' --exclude '.well-known' --exclude '/uploads' -e "ssh -i ./auth/identity.pem -p2222" ./dist/dslak-website/* cdr@2.238.194.8:/www/dslak.it/ |
||||
|
|
||||
|
@ -0,0 +1,25 @@ |
|||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
|
||||
|
import { SitemapComponent } from './sitemap.component'; |
||||
|
|
||||
|
describe('SitemapComponent', () => { |
||||
|
let component: SitemapComponent; |
||||
|
let fixture: ComponentFixture<SitemapComponent>; |
||||
|
|
||||
|
beforeEach(async(() => { |
||||
|
TestBed.configureTestingModule({ |
||||
|
declarations: [ SitemapComponent ] |
||||
|
}) |
||||
|
.compileComponents(); |
||||
|
})); |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
fixture = TestBed.createComponent(SitemapComponent); |
||||
|
component = fixture.componentInstance; |
||||
|
fixture.detectChanges(); |
||||
|
}); |
||||
|
|
||||
|
it('should create', () => { |
||||
|
expect(component).toBeTruthy(); |
||||
|
}); |
||||
|
}); |
@ -0,0 +1,73 @@ |
|||||
|
import { Component, OnInit } from '@angular/core' |
||||
|
import { Router, NavigationEnd } from '@angular/router' |
||||
|
import { ApisService } from '../services/apis.service' |
||||
|
import { environment } from '../../environments/environment' |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'app-sitemap', |
||||
|
templateUrl: './sitemap.component.html', |
||||
|
styleUrls: ['./sitemap.component.scss'] |
||||
|
}) |
||||
|
export class SitemapComponent implements OnInit { |
||||
|
|
||||
|
public basePath = `${environment.BASE_PATH}` |
||||
|
public sitemap: string = '' |
||||
|
|
||||
|
constructor( |
||||
|
private apisService: ApisService, |
||||
|
private router: Router |
||||
|
) { } |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
|
||||
|
const sections = [ |
||||
|
'about', |
||||
|
'portfolio', |
||||
|
'exhibitions', |
||||
|
'installations', |
||||
|
'entertainment', |
||||
|
'performances', |
||||
|
'worhshops' |
||||
|
] |
||||
|
|
||||
|
sections.forEach((e) => { |
||||
|
this.sitemap += `<url><loc>${this.basePath}/${e}</loc></url>\n` |
||||
|
}) |
||||
|
|
||||
|
this.apisService.getPortfolio('portfolio').toPromise().then((response) => { |
||||
|
response.items.forEach((e) => { |
||||
|
this.sitemap += `<url><loc>${this.basePath}/detail/${e.type}/${e.id}/${this.parseTitle(e.title)}</loc></url>\n` |
||||
|
}) |
||||
|
|
||||
|
this.apisService.getPortfolio('exhibitions').toPromise().then((response) => { |
||||
|
response.items.forEach((e) => { |
||||
|
this.sitemap += `<url><loc>${this.basePath}/detail/exhibitions/${e.id}/${this.parseTitle(e.title)}</loc></url>\n` |
||||
|
}) |
||||
|
|
||||
|
this.download() |
||||
|
|
||||
|
},(error) => { |
||||
|
console.error(error) |
||||
|
}).catch((e) => { |
||||
|
console.error(e) |
||||
|
}) |
||||
|
|
||||
|
},(error) => { |
||||
|
console.error(error) |
||||
|
}).catch((e) => { |
||||
|
console.error(e) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
parseTitle(title): string { |
||||
|
return title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-').replace('--', '-').replace('--', '-') |
||||
|
} |
||||
|
|
||||
|
download() { |
||||
|
const header = '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' |
||||
|
const footer = '\n</urlset>' |
||||
|
const blob = new Blob([`${header}${this.sitemap}${footer}`], { type: 'text/xml' }) |
||||
|
const url= window.URL.createObjectURL(blob) |
||||
|
window.location.assign(url) |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue