Skip to content

Commit

Permalink
baseUrl in config sets part 2 and normalize rss paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Nov 8, 2024
1 parent f70d820 commit 3d4b558
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Added `version` alias information to config
* Fixed bug preventing user specified `buildEnd` and `transformPageData` from running after theme's
* Fixed bug preventing `mvb` from correctly setting the `mvbase`
* Fixed duplicate `//` in generated `rss` feed
* Improved `mvb` and `root` link normalization
* Improved `VPLVersionLink` to only need `version` input
* Updated to [[email protected]](https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md)
Expand Down
7 changes: 4 additions & 3 deletions config/landov3.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function({
'https://localhost',
'http://docs.lando.dev',
'https://docs.lando.dev',
getBaseUrl(),
);

// if plugin then add netlify stuff
Expand Down Expand Up @@ -94,7 +95,7 @@ export default function({
}],
},
sitemap: {
hostname: 'https://docs.lando.dev/',
hostname: getBaseUrl() ?? 'https://docs.lando.dev/',
lastmodDateOnly: false,
transformItems: items => {
for (const item of items) {
Expand All @@ -108,8 +109,8 @@ export default function({
themeConfig: {
alert: false,
autometa: {
canonicalUrl: 'https://docs.lando.dev',
image: `${baseUrl}images/hero.png`,
canonicalUrl: getBaseUrl() ?? 'https://docs.lando.dev/',
image: 'https://docs.lando.dev/images/icon.png',
x: '@devwithlando',
},
carbonAds: {
Expand Down
7 changes: 4 additions & 3 deletions config/landov4.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function({
'https://localhost',
'http://docs.lando.dev',
'https://docs.lando.dev',
getBaseUrl(),
);

// if plugin then add netlify stuff
Expand Down Expand Up @@ -94,7 +95,7 @@ export default function({
}],
},
sitemap: {
hostname: 'https://docs.lando.dev/',
hostname: getBaseUrl() ?? 'https://docs.lando.dev/',
lastmodDateOnly: false,
transformItems: items => {
for (const item of items) {
Expand All @@ -108,8 +109,8 @@ export default function({
themeConfig: {
alert: false,
autometa: {
canonicalUrl: 'https://docs.lando.dev',
image: `${baseUrl}images/hero.png`,
canonicalUrl: getBaseUrl() ?? 'https://docs.lando.dev/',
image: 'https://docs.lando.dev/images/icon.png',
x: '@devwithlando',
},
carbonAds: {
Expand Down
12 changes: 7 additions & 5 deletions node/generate-feeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {default as createContentLoader} from '../utils/create-content-loader.js'
import Debug from 'debug';
import {Feed} from 'feed';

const normalizeUrl = url => url.replace(/([^:]\/)\/+/g, '$1');

// helper to normalize things
const normalizeConfig = (config = {}, feed = 'feed') => {
// pluralize
Expand Down Expand Up @@ -52,11 +54,11 @@ export default async function(siteConfig, {debug = Debug('@lando/generate-feeds'
const feed = new Feed({
title: config.title ?? site.title ?? '',
description: config.description ?? config.description ?? '',
id: config.id ?? href,
link: config.link ?? href,
id: normalizeUrl(config.id ?? href),
link: normalizeUrl(config.link ?? href),
language: config.language ?? 'en',
image: config.image ?? '',
favicon: config.favicon ?? `${href}/favicon.ico`,
favicon: normalizeUrl(config.favicon ?? `${href}/favicon.ico`),
copyright: config.copyright ?? '',
});

Expand All @@ -70,8 +72,8 @@ export default async function(siteConfig, {debug = Debug('@lando/generate-feeds'
// initial payload
const data = {
title,
id: `${href}${url}`,
link: `${href}${url}`,
id: normalizeUrl(`${href}${url}`),
link: normalizeUrl(`${href}${url}`),
description: excerpt !== '' ? excerpt : summary,
content: html,
date: new Date(timestamp),
Expand Down

0 comments on commit 3d4b558

Please sign in to comment.