-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add canonical tag to pages with pagination
- Loading branch information
1 parent
a91fd0c
commit c7a1037
Showing
7 changed files
with
141 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,52 @@ | ||
import { escapeHTML } from '@peertube/peertube-core-utils' | ||
import express from 'express' | ||
import { CONFIG } from '../../../initializers/config.js' | ||
import { WEBSERVER } from '../../../initializers/constants.js' | ||
import { PageHtml } from './page-html.js' | ||
import { TagsHtml } from './tags-html.js' | ||
|
||
export type VideosOrderType = 'local' | 'trending' | 'overview' | 'recently-added' | ||
|
||
export class VideosHtml { | ||
|
||
static async getVideosHTML (type: VideosOrderType, req: express.Request, res: express.Response) { | ||
const html = await PageHtml.getIndexHTML(req, res) | ||
|
||
return this.buildVideosHTML({ | ||
html, | ||
type, | ||
currentPage: req.query.page | ||
}) | ||
} | ||
|
||
// --------------------------------------------------------------------------- | ||
// Private | ||
// --------------------------------------------------------------------------- | ||
|
||
private static buildVideosHTML (options: { | ||
html: string | ||
type: VideosOrderType | ||
currentPage: string | ||
}) { | ||
const { html, currentPage, type } = options | ||
|
||
const title = type === 'recently-added' ? 'Recently added' : type.slice(0, 1).toUpperCase() + type.slice(1) | ||
let customHTML = TagsHtml.addTitleTag(html, title) | ||
customHTML = TagsHtml.addDescriptionTag(customHTML) | ||
|
||
let url = WEBSERVER.URL + '/videos/' + type | ||
|
||
if (currentPage) { | ||
url += `?page=${currentPage}` | ||
} | ||
|
||
return TagsHtml.addTags(customHTML, { | ||
url, | ||
|
||
escapedSiteName: escapeHTML(CONFIG.INSTANCE.NAME), | ||
escapedTitle: title, | ||
|
||
forbidIndexation: false | ||
}, {}) | ||
} | ||
} |
This file contains 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
This file contains 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