Skip to content

Update to astro 5 and svelte 5 ✋🏻 #3047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d047b4f
upgrade to astro and svelte 5, main-site, docs, pipeline-results done
mashehu Feb 6, 2025
f64b922
run prettier
mashehu Feb 10, 2025
24d8fe2
fix event listing
mashehu Feb 13, 2025
437f188
fix missing star/end for event content collection
mashehu Feb 13, 2025
4ac048c
fix layout in start page
mashehu Feb 13, 2025
d318d86
show year in blog listing
mashehu Feb 13, 2025
e2e5141
reset filterbar on empty fielters
mashehu Feb 13, 2025
f49f8a1
fix special interest group rendering
mashehu Feb 13, 2025
0652ede
remove duplicated shop entry in navbar
mashehu Feb 13, 2025
03c1096
fix google all day event rendering
mashehu Feb 13, 2025
3976556
add github file loader
mashehu Feb 17, 2025
54d5f98
use new file loader to create config collection
mashehu Feb 17, 2025
426e79c
add pipeline configs to hpc config pages
mashehu Feb 18, 2025
77d0c69
add date to config pages
mashehu Feb 18, 2025
d9f6951
don't always add dates to files loaded from github to save api queries
mashehu Feb 18, 2025
d7ae933
fix checkbox and sidebar component
mashehu Feb 18, 2025
d3201be
fix special interest group listing
mashehu Feb 18, 2025
e666bdc
update pipeline and component listing cards to new snippet syntax
mashehu Feb 18, 2025
b1de5d4
update modules-subowrkflows to astro 5
mashehu Feb 18, 2025
8928477
update ts configs according to astro 5 migration guides
mashehu Feb 18, 2025
954194b
fix github queries
mashehu Feb 20, 2025
3f0242b
only render config files with documentation
mashehu Feb 20, 2025
f038b42
polish config pages
mashehu Feb 20, 2025
5724362
exclude pipeline configs for hpc pages
mashehu Feb 20, 2025
525e725
fix github token handling
mashehu Feb 20, 2025
87e44dc
udpate to astro 3.5.0
mashehu Feb 20, 2025
36940cd
add toc to config pages
mashehu Feb 27, 2025
008ec90
switch pipeilne pages to content loader
mashehu Feb 27, 2025
a9baf44
rewrite loader to allow our specific parsing rules (taken from octoki…
mashehu Feb 27, 2025
cf2952f
update pipelinelisting
mashehu Feb 27, 2025
9e6ace3
fix config pages
mashehu Feb 27, 2025
c903cc6
improve logic in remark plugin
mashehu Feb 27, 2025
bb9d054
add parameters and release loaders
mashehu Feb 27, 2025
a98a6b7
fix parameter pages with empty schema
mashehu Mar 3, 2025
fcad807
avoid duplicated pipelines in components.json listing
mashehu Mar 3, 2025
922f6aa
allow different site contexts
mashehu Mar 3, 2025
bd598db
convert component listing to svelte 5
mashehu Mar 3, 2025
b6aede3
reduce bundle size for markdownwrapper (hopefully)
mashehu Mar 3, 2025
a49cc85
fix pagination element
mashehu Mar 3, 2025
7a2da5d
handle empty meta fields in search
mashehu Mar 3, 2025
8dfbd12
fix subworkflow layout on wide screens
mashehu Mar 3, 2025
b8b3279
remove type from subworkflow input/output table
mashehu Mar 3, 2025
879bd0b
Merge branch 'main' of github.com:nf-core/nf-co.re into update-astro-5
mashehu Mar 4, 2025
6c2adfb
fixing code blocks
mashehu Mar 4, 2025
9313b04
update dependencies
mashehu Mar 4, 2025
c174d3c
fix project modals
mashehu Mar 4, 2025
53bca75
Merge branch 'main' of github.com:nf-core/nf-co.re into update-astro-5
mashehu Mar 4, 2025
fa33b34
fix typeform embed
mashehu Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ repos:
# NOTE https://github.com/pre-commit/pre-commit/issues/3133
additional_dependencies:
- [email protected]
- prettier-plugin-svelte@^3.2.6
- prettier-plugin-svelte@^3.3.3
- prettier-plugin-astro@^0.14.1
files: \.(astro|svelte|mdx|md|yml|yaml)$
5 changes: 4 additions & 1 deletion bin/components.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ export const writeComponentsJson = async () => {
if (index > -1) {
const entry = { name: pipeline.name, version: release.tag_name };
if (components.subworkflows[index].pipelines) {
components.subworkflows[index].pipelines.push(entry);
// check if the pipeline is already in the array
if (!components.subworkflows[index].pipelines.some(e => e.name === entry.name && e.version === entry.version)) {
components.subworkflows[index].pipelines.push(entry);
}
} else {
components.subworkflows[index].pipelines = [entry];
}
Expand Down
26 changes: 0 additions & 26 deletions bin/pipelines.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { promises as fs, writeFileSync, existsSync } from 'fs';
import yaml from 'js-yaml';
import path, { join } from 'path';
import ProgressBar from 'progress';
import cache from './cache.js';

// get current path
const __dirname = path.resolve();
Expand Down Expand Up @@ -406,31 +405,6 @@ export const writePipelinesJson = async () => {
return component.replace('/', '_');
});
}

// cache release body except for dev
if (release.tag_name !== 'dev') {
const cache_key = `${name}/${release.tag_name}/body`;
// const is_cached = cache.getSync(cache_key, false) && cache.getSync(cache_key, false).length > 0;
const is_cached = false;
if (!is_cached) {
// wrap github urls in markdown links if they are to the same repo and not already inside a link
release.body = release.body.replaceAll(
/(?<!\]\()https:\/\/github\.com\/nf-core\/([^\/]+)\/([^\/]+)\/([^\/\n]*)(?![\)\]])/g,
(match, p1, p2, p3) => {
if (p1 === name && ['pull', 'issues', 'compare'].includes(p2)) {
const prefix = p2 !== 'compare' ? '#' : '';
return `[${prefix}${p3}](${match})`;
}
return match;
},
);
// replace usernames with links to github profiles
release.body = release.body.replaceAll(/@(\w+([-]\w+)*)/g, (match, p1) => {
return `[${match}](https://github.com/${p1})`;
});
cache.set(cache_key, release.body);
}
}
return { tag_name, published_at, tag_sha, has_schema, doc_files, components };
}),
);
Expand Down
190 changes: 190 additions & 0 deletions bin/remark-github-markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import { visit } from 'unist-util-visit';
import { toString } from 'mdast-util-to-string';
import { h } from 'hastscript';

// Precompile regex patterns for better performance
const SPECIAL_FILES_REGEX = /^(\.github\/CONTRIBUTING\.md|CITATIONS\.md|CHANGELOG\.md)$/;
const MDX_ANCHOR_REGEX = /\.mdx?#/;
const ADMONITION_REGEX = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)/;
const IMG_SRC_REGEX = /<img(.*?)src="(.*?)"/g;
const SOURCE_SRCSET_REGEX = /<source(.*?)srcset="(.*?)"/g;

/**
* Remark plugin to process GitHub markdown content
* - Fixes image URLs
* - Fixes link URLs
* - Converts GitHub admonitions
* - Cleans up headers
* - Fixes code blocks
*/
export default function remarkGitHubMarkdown(options = {}) {
const { org = 'nf-core', repo, ref, parent_directory = '' } = options;
return (tree, file) => {
// For backward compatibility, also check file.data
const fileRepo = file.data?.repo || repo;
const fileRef = file.data?.ref || ref;
const fileParentDir = file.data?.parent_directory || parent_directory;

if (!fileRepo || !fileRef) {
console.log('Skipping processing - missing repo or ref');
return;
}

const baseRawUrl = `https://raw.githubusercontent.com/${org}/${fileRepo}/${fileRef}/`;
const baseRepoUrl = `https://github.com/${org}/${fileRepo}/blob/${fileRef}/`;

visit(tree, (node, index, parent) => {
switch (node.type) {
case 'image':
if (node.url && !node.url.startsWith('http')) {
node.url = `${baseRawUrl}${fileParentDir}/${node.url}`;
}
break;

case 'link':
if (node.url && !node.url.startsWith('http')) {
// Handle special files
if (SPECIAL_FILES_REGEX.test(node.url)) {
node.url = `${baseRepoUrl}${node.url}`;
}
// Handle assets
else if (node.url.includes('../assets/')) {
node.url = `${baseRepoUrl}${node.url.replace('../assets/', 'assets/')}`;
}
// Handle .md/.mdx links with anchors
else if (MDX_ANCHOR_REGEX.test(node.url)) {
node.url = node.url.replace(MDX_ANCHOR_REGEX, '#');
}
}
break;

case 'code':
if (node.lang === 'nextflow') {
node.lang = 'groovy';
}
break;

case 'heading':
if (node.depth === 1) {
const headingText = toString(node);
if (headingText.startsWith(`nf-core/${fileRepo}: `)) {
// Replace the first child's text content
if (node.children[0] && node.children[0].type === 'text') {
node.children[0].value = node.children[0].value.replace(`nf-core/${fileRepo}: `, '');
}
}
}
break;

case 'blockquote':
if (node.children && node.children.length > 0) {
const firstChild = node.children[0];

if (firstChild.type === 'paragraph' &&
firstChild.children &&
firstChild.children.length > 0) {

const firstText = firstChild.children[0];
if (firstText.type === 'text' && firstText.value.startsWith('[!')) {
const match = firstText.value.match(ADMONITION_REGEX);

if (match) {
// Get the admonition type and handle special cases
let type = match[1].toLowerCase();
if (type === 'important') type = 'info';
else if (type === 'caution') type = 'danger';

// Create a directive node
const directiveNode = {
type: 'containerDirective',
name: type,
attributes: {},
children: [],
data: {
hName: 'div',
hProperties: {}
}
};

// Add title attribute for special cases
if (match[1] === 'IMPORTANT') {
directiveNode.attributes.title = 'Important';
} else if (match[1] === 'CAUTION') {
directiveNode.attributes.title = 'Caution';
}

// If there's content on the same line as the admonition marker
if (match[2]) {
directiveNode.children.push({
type: 'paragraph',
children: [{
type: 'text',
value: match[2]
}]
});
}

// Add the rest of the blockquote's content to the directive
for (let i = 1; i < node.children.length; i++) {
directiveNode.children.push(node.children[i]);
}

// Replace the blockquote with the directive node
parent.children[index] = directiveNode;
return [visit.SKIP, index];
}
}
}
}
break;

case 'html':
if (node.value.includes('<img') && !node.value.includes('src="http')) {
node.value = node.value.replace(
IMG_SRC_REGEX,
(match, attrs, src) => `<img${attrs}src="${baseRawUrl}${fileParentDir}/${src}"`
);
}

if (node.value.includes('<source') && !node.value.includes('srcset="http')) {
node.value = node.value.replace(
SOURCE_SRCSET_REGEX,
(match, attrs, src) => `<source${attrs}srcset="${baseRawUrl}${fileParentDir}/${src}"`
);
}
break;
}
});

// Clean up introduction - this requires manipulating the tree structure
// Find the first "Introduction" heading and remove everything before it
const introIndex = tree.children.findIndex(
node => node.type === 'heading' &&
node.depth === 2 &&
toString(node) === 'Introduction'
);

if (introIndex > 0) {
tree.children = tree.children.slice(introIndex);
}

// Remove warning sections
const warningIndex = tree.children.findIndex(
node => node.type === 'heading' &&
node.depth === 2 &&
toString(node).includes(':warning:')
);

if (warningIndex >= 0) {
// Find the next heading after the warning
const nextHeadingIndex = tree.children.findIndex(
(node, i) => i > warningIndex && node.type === 'heading'
);

if (nextHeadingIndex > warningIndex) {
// Remove everything between warning and next heading
tree.children.splice(warningIndex, nextHeadingIndex - warningIndex);
}
}
};
}
Loading
Loading