Skip to content

Commit

Permalink
Merge branch 'main' into v3-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero authored Feb 6, 2025
2 parents 9f6b13c + 92ffcb9 commit 523a239
Show file tree
Hide file tree
Showing 15 changed files with 448 additions and 22 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project try to adheres to [Semantic Versioning](https://semver.org/).
Go to the `v1` branch to see the changelog of Lume 1.

## [Unreleased]
### Added
- Feed plugin: New option `info.hubs` [#725].
- Redirects plugin: Add `isRedirect=true` data field to HTML redirect pages.
- Sitemap plugin: Set default query to `isRedirect!=true`.

### Fixed
- Sass plugin: Allow additional importers [#727].
- Components: Reorder css code to ensure `@import` rules are first.
- Updated components: `std`, `decap-cms`, `terser` and some icons.

## [2.5.1] - 2025-01-28
### Added
- Support for LumeCMS v0.9, that can perform git operations and restart the build.
Expand Down Expand Up @@ -694,7 +705,10 @@ Go to the `v1` branch to see the changelog of Lume 1.
[#715]: https://github.com/lumeland/lume/issues/715
[#716]: https://github.com/lumeland/lume/issues/716
[#722]: https://github.com/lumeland/lume/issues/722
[#725]: https://github.com/lumeland/lume/issues/725
[#727]: https://github.com/lumeland/lume/issues/727

[Unreleased]: https://github.com/lumeland/lume/compare/v2.5.1...HEAD
[2.5.1]: https://github.com/lumeland/lume/compare/v2.5.0...v2.5.1
[2.5.0]: https://github.com/lumeland/lume/compare/v2.4.3...v2.5.0
[2.4.3]: https://github.com/lumeland/lume/compare/v2.4.2...v2.4.3
Expand Down
20 changes: 15 additions & 5 deletions core/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,12 @@ export default class Source {
for (const [type, path] of Object.entries(files)) {
const code = this.extraCode.get(type);

if (code && code.size) {
pages.push([
path,
Array.from(code.values()).join("\n"),
]);
if (code?.size) {
const content = type === "css"
? Array.from(code.values()).sort(sortCSS).join("\n")
: Array.from(code.values()).join("\n");

pages.push([path, content]);
}
}

Expand Down Expand Up @@ -712,4 +713,13 @@ function createFile(
path: entry.path.slice(0, -ext.length),
entry,
});

function sortCSS(a: string, b: string) {

Check failure on line 717 in core/source.ts

View workflow job for this annotation

GitHub Actions / Run tests (2.1, macos-latest)

`sortCSS` is never used
if (a.includes("@import")) {
return -1;
}
if (b.includes("@import")) {
return 1;
}
return 0;
}
4 changes: 2 additions & 2 deletions deps/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const catalogs: Catalog[] = [
{
// https://simpleicons.org/
id: "simpleicons",
src: "https://cdn.jsdelivr.net/npm/simple-icons@14.4.0/icons/{name}.svg",
src: "https://cdn.jsdelivr.net/npm/simple-icons@14.5.0/icons/{name}.svg",
},
{
// https://tabler.io/icons
Expand Down Expand Up @@ -186,7 +186,7 @@ export const catalogs: Catalog[] = [
// https://primer.style/foundations/icons
id: "octicons",
src:
"https://cdn.jsdelivr.net/npm/@primer/octicons@19.14.0/build/svg/{name}-{variant}.svg",
"https://cdn.jsdelivr.net/npm/@primer/octicons@19.15.0/build/svg/{name}-{variant}.svg",
variants: ["24", "16", "12", "48", "96"],
},
{
Expand Down
4 changes: 2 additions & 2 deletions deps/terser.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { minify } from "npm:terser@5.37.0";
export type { MinifyOptions } from "npm:terser@5.37.0";
export { minify } from "npm:terser@5.38.0";
export type { MinifyOptions } from "npm:terser@5.38.0";
23 changes: 18 additions & 5 deletions plugins/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export interface FeedInfoOptions {
/** The feed language */
lang?: string;

/** The WebSub hubs for the feed */
hubs?: string[];

/** The feed generator. Set `true` to generate automatically */
generator?: string | boolean;

Expand Down Expand Up @@ -137,6 +140,7 @@ export interface FeedData {
description: string;
published: Date;
lang: string;
hubs?: string[];
generator?: string;
items: FeedItem[];
author?: Author;
Expand Down Expand Up @@ -186,6 +190,7 @@ export function feed(userOptions?: Options) {
description: getPlainDataValue(rootData, info.description),
published: getDataValue(rootData, info.published),
lang: getDataValue(rootData, info.lang),
hubs: info.hubs,
url: site.url("", true),
generator: info.generator === true
? defaultGenerator
Expand Down Expand Up @@ -280,11 +285,17 @@ function generateRss(data: FeedData, file: string): string {
channel: {
title: data.title,
link: data.url,
"atom:link": {
"@href": file,
"@rel": "self",
"@type": "application/rss+xml",
},
"atom:link": [
{
"@href": file,
"@rel": "self",
"@type": "application/rss+xml",
},
...(data.hubs ?? []).map((hub) => ({
"@href": hub,
"@rel": "hub",
})),
],
description: data.description,
lastBuildDate: data.published.toUTCString(),
language: data.lang,
Expand Down Expand Up @@ -330,6 +341,8 @@ function generateJson(data: FeedData, file: string): string {
title: data.title,
home_page_url: data.url,
feed_url: file,
hubs: data.hubs &&
data.hubs.map((hub) => ({ "type": "WebSub", "feed_url": hub })),
description: data.description,
author: data.author,
icon: data.image,
Expand Down
2 changes: 1 addition & 1 deletion plugins/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function html(redirects: Redirect[], site: Site): void {
<a href="${to}">Click here if you are not redirected.</a>
</body>
</html>`;
const page = Page.create({ url, content });
const page = Page.create({ url, content, isRedirect: true });
site.pages.push(page);
}
}
Expand Down
4 changes: 1 addition & 3 deletions plugins/sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export function sass(userOptions?: Options) {
}
}

throw new Error(
`File cannot be canonicalized: ${url} (${pathname})`,
);
return null;
},
async load(url: URL) {
const pathname = fromFileUrl(url);
Expand Down
7 changes: 5 additions & 2 deletions plugins/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export interface Options {
/** The sitemap file name */
filename?: string;

/** The query to search pages included in the sitemap */
/**
* The query to search pages included in the sitemap
* @default "isRedirect!=true" excludes redirect pages produced by the redirects plugin
*/
query?: string;

/** The values to sort the sitemap */
Expand All @@ -37,7 +40,7 @@ export interface Options {
// Default options
export const defaults: Options = {
filename: "/sitemap.xml",
query: "",
query: "isRedirect!=true",
sort: "url=asc",
lastmod: "date",
};
Expand Down
8 changes: 6 additions & 2 deletions tests/__snapshots__/feed.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ snapshot[`RSS plugin 3`] = `
},
},
{
content: '{"version":"https://jsonfeed.org/version/1","title":"My RSS Feed","home_page_url":"https://example.com/","feed_url":"https://example.com/feed.json","author":{"name":"Laura Rubio"},"icon":"https://example.com/image.png","favicon":"https://example.com/icon.svg","items":[{"id":"https://example.com/page5/","url":"https://example.com/page5/","title":"PAGE 5","author":{"name":"Óscar","url":"https://oscarotero.com"},"content_html":"Content of Page 5","date_published":"Thu, 21 Jun 1979 23:45:00 GMT","date_modified":"Thu, 21 Jun 1979 23:45:00 GMT"}]}',
content: '{"version":"https://jsonfeed.org/version/1","title":"My RSS Feed","home_page_url":"https://example.com/","feed_url":"https://example.com/feed.json","hubs":[{"type":"WebSub","feed_url":"https://example.com/hub1"},{"type":"WebSub","feed_url":"https://example.com/hub2"}],"author":{"name":"Laura Rubio"},"icon":"https://example.com/image.png","favicon":"https://example.com/icon.svg","items":[{"id":"https://example.com/page5/","url":"https://example.com/page5/","title":"PAGE 5","author":{"name":"Óscar","url":"https://oscarotero.com"},"content_html":"Content of Page 5","date_published":"Thu, 21 Jun 1979 23:45:00 GMT","date_modified":"Thu, 21 Jun 1979 23:45:00 GMT"}]}',
data: {
basename: "feed",
content: '{"version":"https://jsonfeed.org/version/1","title":"My RSS Feed","home_page_url":"https://example.com/","feed_url":"https://example.com/feed.json","author":{"name":"Laura Rubio"},"icon":"https://example.com/image.png","favicon":"https://example.com/icon.svg","items":[{"id":"https://example.com/page5/","url":"https://example.com/page5/","title":"PAGE 5","author":{"name":"Óscar","url":"https://oscarotero.com"},"content_html":"Content of Page 5","date_published":"Thu, 21 Jun 1979 23:45:00 GMT","date_modified":"Thu, 21 Jun 1979 23:45:00 GMT"}]}',
content: '{"version":"https://jsonfeed.org/version/1","title":"My RSS Feed","home_page_url":"https://example.com/","feed_url":"https://example.com/feed.json","hubs":[{"type":"WebSub","feed_url":"https://example.com/hub1"},{"type":"WebSub","feed_url":"https://example.com/hub2"}],"author":{"name":"Laura Rubio"},"icon":"https://example.com/image.png","favicon":"https://example.com/icon.svg","items":[{"id":"https://example.com/page5/","url":"https://example.com/page5/","title":"PAGE 5","author":{"name":"Óscar","url":"https://oscarotero.com"},"content_html":"Content of Page 5","date_published":"Thu, 21 Jun 1979 23:45:00 GMT","date_modified":"Thu, 21 Jun 1979 23:45:00 GMT"}]}',
page: [
"src",
"data",
Expand All @@ -200,6 +200,8 @@ snapshot[`RSS plugin 3`] = `
<title>My RSS Feed</title>
<link>https://example.com/</link>
<atom:link href="https://example.com/feed.rss" rel="self" type="application/rss+xml"/>
<atom:link href="https://example.com/hub1" rel="hub"/>
<atom:link href="https://example.com/hub2" rel="hub"/>
<lastBuildDate>Wed, 01 Jan 2020 00:00:00 GMT</lastBuildDate>
<language>en</language>
<generator>https://lume.land</generator>
Expand Down Expand Up @@ -231,6 +233,8 @@ snapshot[`RSS plugin 3`] = `
<title>My RSS Feed</title>
<link>https://example.com/</link>
<atom:link href="https://example.com/feed.rss" rel="self" type="application/rss+xml"/>
<atom:link href="https://example.com/hub1" rel="hub"/>
<atom:link href="https://example.com/hub2" rel="hub"/>
<lastBuildDate>Wed, 01 Jan 2020 00:00:00 GMT</lastBuildDate>
<language>en</language>
<generator>https://lume.land</generator>
Expand Down
3 changes: 3 additions & 0 deletions tests/__snapshots__/redirects.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ snapshot[`redirects plugin 3`] = `
<a href="/page1/">Click here if you are not redirected.</a>
</body>
</html>',
isRedirect: true,
page: [
"src",
"data",
Expand Down Expand Up @@ -180,6 +181,7 @@ snapshot[`redirects plugin 3`] = `
<a href="/page2/">Click here if you are not redirected.</a>
</body>
</html>',
isRedirect: true,
page: [
"src",
"data",
Expand Down Expand Up @@ -219,6 +221,7 @@ snapshot[`redirects plugin 3`] = `
<a href="/page2/">Click here if you are not redirected.</a>
</body>
</html>',
isRedirect: true,
page: [
"src",
"data",
Expand Down
Loading

0 comments on commit 523a239

Please sign in to comment.