| layout | main.njk |
|---|---|
| permalink | 404.html |
| eleventyExcludeFromCollections | true |
| title | 404 |
// @module: esnext
// @target: es2017
import { Model, DataObject, ModelBuilder, DataObjectService, Absolute2DPosition, AbsolutePosition } from '@openhps/core';
const model: Model = await ModelBuilder.create().build();
class HTMLDataObject extends DataObject { }
class URLPosition extends Absolute2DPosition implements AbsolutePosition {
address: string = "";
}
const request = {
url: new URLPosition()
};
class Page extends HTMLDataObject {
show() { }
}
const errorPage: Page = new Page();
// ---cut---
// Find the data service responsible for HTML data objects
const service: DataObjectService<Page> = model.findDataService(HTMLDataObject);
// Find the data object by its current position
service.findByPosition(request.url).then((pages: Page[]) => {
if (pages.length === 0) {
// No objects found at the position
errorPage.show();
return;
}
// Show the first result, assuming the position is unique
pages[0].show();
});We could not track the position of the page you are looking for!
If it moved, you should try to getPosition() of the page. It is also possible we deleted the page, in that case we have lots of other pages that might be of interest to you :)